在通用应用程序中固定Iphone的方向

Shi*_*ver 1 iphone orientation

我已经开发了一个通用应用程序,我想支持IPAD的所有方向,但对于Iphone,我只想要UIInterfaceOrientationPortrait和UIInterfaceOrientationPortraitUpsideDown,我只有这个

-(BOOL)shouldAutorotate {
    if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone){
        return NO;
    }else{
        return YES;
    }
}
- (NSUInteger)supportedInterfaceOrientations{

     if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone){
         return UIInterfaceOrientationMaskPortrait;
     }else{
        return UIInterfaceOrientationMaskAll;
     }

} 
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
     if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone){

    return interfaceOrientation == UIInterfaceOrientationPortrait || interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown ;
     }else{
         return YES;
     }

}
Run Code Online (Sandbox Code Playgroud)

但仍然没有停止在景观中的方向

Iro*_*ill 6

简单地禁用除所有其他方向UIInterfaceOrientationPortraitUIInterfaceOrientationPortraitUpsideDown一个用于iPhone摘要像下面的说明.在图片中,颠倒被禁用请启用它.谢谢.

在此输入图像描述