preferredInterfaceOrientationForPresentation must return a supported interface orientation

前端 未结 4 602
星月不相逢
星月不相逢 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:50

    Your code should look like this:

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

    Also, make sure in your Info.plist you have set the correct orientations for you app because what you return from supportedInterfaceOrientations is intersected with the Info.plist and if it can't find a common one then you'll get that error.

提交回复
热议问题