本文介绍了力风景ios 7的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已尝试采用以下方法将风景强制置于我的视图中:

- (NSUInteger)supportedInterfaceOrientations {返回 UIInterfaceOrientationMaskLandscape;}- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {返回 UIInterfaceOrientationLandscapeLeft;}- (BOOL)shouldAutorotate{返回是;}

都没有用.请注意,我正在模拟器和 iPad 上进行测试.

谢谢

解决方案

以下是我使用 NavigationViewController 强制我的一个视图为 Landscape 的方法:

  1. 实现了这个答案:https://stackoverflow.com/a/12662433/2394787

  2. 在视图控制器中导入的消息:objc/message.h

  3. 在viewDidLoad方法中添加了这行代码:

objc_msgSend([UIDevice currentDevice], @selector(setOrientation:), UIInterfaceOrientationLandscapeLeft);

希望对某人有所帮助.

I've tried to following methods to force landscape on one my views:

- (NSUInteger)supportedInterfaceOrientations {
    return UIInterfaceOrientationMaskLandscape;
}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
    return UIInterfaceOrientationLandscapeLeft;
}

- (BOOL)shouldAutorotate{
    return YES;
}

Neither did work. Note that I'm testing on the simulator and on an iPad.

Thanks

解决方案

Here is how I forced one of my views to be Landscape using NavigationViewController:

  1. Implemented this answer: https://stackoverflow.com/a/12662433/2394787

  2. Imported message in the View controller: objc/message.h

  3. Added this line of code in the viewDidLoad method:

Hope it helps someone.

这篇关于力风景ios 7的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-15 15:10