preferredInterfaceOrientationForPresentation must return a supported interface orientation

前端 未结 4 568
星月不相逢
星月不相逢 2020-11-29 07:11

This error doesn\'t make sense, as the preferred orientation UIInterfaceOrientationLandscapeRight is returned by the supported orientation

//iOS         


        
4条回答
  •  醉梦人生
    2020-11-29 07:58

    supportedInterfaceOrientations is only called, if shouldAutorotate is set to YES

    - (BOOL)shouldAutorotate
    {
        return YES;
    }
    
    - (NSUInteger)supportedInterfaceOrientations
    {
        return UIInterfaceOrientationMaskLandscape;
    }
    
    - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
    {
        return UIInterfaceOrientationLandscapeRight;
    }
    

    The easiest approach for me, is only to set the Info.plist

    info.plist

    If you like to support iOS 5 use this code in your view controllers.

    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
    {
    return UIInterfaceOrientationIsLandscape(interfaceOrientation);
    }
    

提交回复
热议问题