How to constrain autorotation to a single orientation for some views, while allowing all orientations on others?

后端 未结 5 1319
孤街浪徒
孤街浪徒 2020-12-01 03:44

This question is about iOS device rotation and multiple controlled views in a UINavigationController. Some views should be constrained to portrait orientation, and

5条回答
  •  渐次进展
    2020-12-01 04:10

    In iOS 6, this has become a very simple issue. Simply create a special class for the views you want to autorotate. Then, in your rootVC, add this.

    -(BOOL)shouldAutorotate{
           BOOL should = NO;
    
           NSLog(@"%@", [self.viewControllers[self.viewControllers.count-1] class]);
           if ([self.viewControllers[self.viewControllers.count-1] isKindOfClass:[YourAutorotatingClass class]]) {
                 should = YES;
           }
    
    
           return should;
    }
    

    I know this is an old question, but I thought it worthwhile to mention.

提交回复
热议问题