dio*_*Dev 10 landscape viewcontroller ios ios7
我试图按照方法强制观察我的观点:
- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskLandscape;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
return UIInterfaceOrientationLandscapeLeft;
}
- (BOOL)shouldAutorotate{
return YES;
}
Run Code Online (Sandbox Code Playgroud)
两者都没有奏效.请注意,我正在模拟器和iPad上进行测试.
谢谢
dio*_*Dev 22
以下是我使用NavigationViewController将我的一个视图强制为Landscape的方法:
在View控制器中导入的消息:objc/message.h
在viewDidLoad方法中添加了以下代码行:
objc_msgSend([UIDevice currentDevice],@ selector(setOrientation :),UIInterfaceOrientationLandscapeLeft);
希望它可以帮助某人.
接受的答案似乎不适用于iOS 7.1.2.(它在模拟器上工作,但在设备上运行时不起作用.)
这似乎工作:
[[UIDevice currentDevice] setValue:[NSNumber numberWithInteger:UIInterfaceOrientationPortrait] forKey:@"orientation"];
[[UIDevice currentDevice] setValue:[NSNumber numberWithInteger:UIInterfaceOrientationLandscapeLeft] forKey:@"orientation"];
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
14892 次 |
| 最近记录: |