How to change only one ViewController to landscape mode with UINavigationcontroller

谁说我不能喝 提交于 2019-12-12 04:36:19

问题


I have two view controllers,I have some videos in FirstViewController,if I click on video it will display on SecondViewController with landscape mode,after clicking back button again the FirstViewController should appear in Potrait mode.Here is my code

-(NSUInteger)supportedInterfaceOrientations
 {

     return UIInterfaceOrientationMaskLandscape;
 }

but it not works for me.

Thanks


回答1:


I made a simple workaround at this question a few weeks ago. If you want, you can link the return value of the rootviewcontroller shouldAutoRotate/supportedInterfaceOrientation to the presentation of the second view controller doing this

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;
}

And in the secondView controller you have to call the setter method in the viewDidAppear to modify values. Then, in the viewDidDisappear, or when you dismiss the controller, you will reset the values.



来源:https://stackoverflow.com/questions/26752223/how-to-change-only-one-viewcontroller-to-landscape-mode-with-uinavigationcontrol

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!