shouldAutorotateToInterfaceOrientation: never called

前端 未结 2 640
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-22 08:51

I set supported Interface Orientations to be all except Portrait upside down under Deployment Info.

I would like to override shouldAutorotateToInterfaceOrientation: for

2条回答
  •  臣服心动
    2021-01-22 09:13

    Its Working for me:

    - (BOOL)shouldAutorotate {
        return YES;
    }
    
    - (NSUInteger)supportedInterfaceOrientations {
        NSUInteger orientations = UIInterfaceOrientationMaskPortrait;
        if ([self isKindOfClass:[YourViewController class]]) { // Your view class
            orientations |= UIInterfaceOrientationMaskPortraitUpsideDown;
        }
        return orientations;
    }
    

    orientations:

    orientations |= UIInterfaceOrientationMaskLandscapeLeft;
    orientations |= UIInterfaceOrientationMaskLandscapeRight;
    

提交回复
热议问题