如果有NAVC可能会不好用
你可以复写viewcontroller的下面几个模板函数,试试。
- (BOOL)shouldAutorotate NS_AVAILABLE_IOS(6_0);当前viewcontroller是否支持转屏
- (NSUInteger)supportedInterfaceOrientations;当前viewcontroller支持哪些转屏方向
-(UIInterfaceOrientation)preferredInterfaceOrientationForPresentation当前viewcontroller默认的屏幕方向
可以试试这个方法:
if
([[
UIDevice
currentDevice
]
respondsToSelector
:
@selector
(setOrientation:)]) {
SEL selector = NSSelectorFromString ( @"setOrientation:" );
NSInvocation *invocation = [ NSInvocation invocationWithMethodSignature :[ UIDevice instanceMethodSignatureForSelector :selector]];
[invocation setSelector :selector];
[invocation setTarget :[ UIDevice currentDevice ]];
SEL selector = NSSelectorFromString ( @"setOrientation:" );
NSInvocation *invocation = [ NSInvocation invocationWithMethodSignature :[ UIDevice instanceMethodSignatureForSelector :selector]];
[invocation setSelector :selector];
[invocation setTarget :[ UIDevice currentDevice ]];
int val =
UIInterfaceOrientationLandscapeLeft
; // 选择屏幕旋转的样式
[invocation setArgument :&val atIndex : 2 ];
[invocation invoke];
}