如何使用UINavigationcontroller仅将一个ViewController更改为横向模式
我有两个视图控制器,我在FirstViewController中有一些video,如果我点击video,它将显示在横向模式SecondViewController,再次单击返回button后FirstViewController应该出现在Potrait模式。这里是我的代码
-(NSUInteger)supportedInterfaceOrientations { return UIInterfaceOrientationMaskLandscape; }
但它不适合我。
谢谢
几个星期前,我在这个问题上做了一个简单的解决方法。 如果你愿意的话,你可以将rootviewcontroller的返回值连接到第二个视图控制器的呈现方式shouldAutoRotate / supportedInterfaceOrientation
RootViewController的
@property (nonatomic, retain) BOOL autoRotate; @property (nonatomic, retain) UIInterfaceOrientation interfaceOrientation; -(void)setAutorate:(BOOL)newValue { _autoRotate = newValue; } -(void)setInterfaceOrientation: (UIInterfaceOrientation)newInterface { _interfaceOrientation = newInterface; } -(BOOL)shouldAutorotate { return _autoRotate; } -(UIInterfaceOrientation)supportedInterfaceOrientation { return _interfaceOrientation; }
而在第二个视图控制器中,您必须调用viewDidAppear中的setter方法来修改值。 然后,在viewDidDisappear中,或者当您closures控制器时,您将重置值。