在 iPad 应用程序中,我使用 UISplitViewController。
当应用程序以纵向模式启动时,我需要强制显示主弹出窗口。
现在我正在使用这段代码,它在 iOS 5.0 上运行良好。
if (UIInterfaceOrientationIsPortrait(self.interfaceOrientation)) {
if ([[[AppDelegate sharedAppDelegate] splitViewController] respondsToSelector:[[[AppDelegate sharedAppDelegate] btnMenu] action]]) {
[[[AppDelegate sharedAppDelegate] splitViewController] performSelector:[[[AppDelegate sharedAppDelegate] btnMenu] action]];
}
}
但在 iOS 5.1(带有新型主弹出窗口)中,行为似乎是随机的。
有时弹出窗口会全屏显示,有时效果很好。
对5.1有什么建议吗?
这里没有 5.1 的建议,但有 8.0 的建议:
现在有了 iOS8,有很多新方法UISplitViewController
配置。
在你的情况下,只需设置正确的值preferredDisplayMode
,例如在 masterViewController 中viewDidLoad
.
Objective-C:
- (void)viewDidLoad {
// configuring splitviewcontroller
self.splitViewController.preferredDisplayMode = UISplitViewControllerDisplayModeAllVisible;
//....
}
Swift:
override func viewDidLoad() {
self.splitViewController?.preferredDisplayMode = UISplitViewControllerDisplayMode.AllVisible
}
但这当然仅限于iOS8。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)