建立一个单例工具类,带有一个flag属性。里面实现一个类似方法:
- (UIInterfaceOrientationMask)interfaceOrientationMask {
if (self.flag == 1) {
return UIInterfaceOrientationMaskLandscape;
}else {
return UIInterfaceOrientationMaskPortrait;
}
}
appDelegate里实现application:supportedInterfaceOrientationsForWindow:方法,直接返回这个方法就可以了。
- (UIInterfaceOrientationMask)interfaceOrientationMask {
if (self.flag == 1) {
return UIInterfaceOrientationMaskLandscape;
}else {
return UIInterfaceOrientationMaskPortrait;
}
}
appDelegate里实现application:supportedInterfaceOrientationsForWindow:方法,直接返回这个方法就可以了。
需要横屏的地方把单例的flag改成1,这个页面撤销的时候改回0。