iOS开发(iPad/iPhone)设置app界面 默认横向显示的两种方法

方法一:

用文本编辑工具 打开工程属性文件,也就是那个 xx-info.plist文件,把下面蓝色的部分复制进去,保存。重新编译下,OK。





    UIInterfaceOrientation
    UIInterfaceOrientationLandscapeRight
    UISupportedInterfaceOrientations
    
        UIInterfaceOrientationLandscapeRight
        UIInterfaceOrientationLandscapeLeft
    



方法二:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations
    //return (interfaceOrientation == UIInterfaceOrientationPortrait);
    //只支持横屏

    if(UIInterfaceOrientationIsLandscape(interfaceOrientation))
    {
        return YES;
    }
    /*else//只支持竖屏
     if(UIInterfaceOrientationIsPortrait(interfaceOrientation))
     {
     return YES;
    
     }
     */

    return NO;
}

你可能感兴趣的:(iOS)