此前有人提出过两个类似的问题:
Forcing an iPad app to show splitView even in Portrait orientation(Like the Settings iPad app)
这两个问题都在很大程度上得到了“未经官方支持 - 自行推送或使用第三方自定义控制器”的回答。
然而,我正在深入研究WWDC 2011 Apple开发者视频(特别是会话102),并且在演示者中大约30分钟声明iOS 5中现在 支持此功能。问题是我不知道如何实现它。这是幻灯片中的代码:
@protocol UISplitViewControllerDelegate
...
// Returns YES if a view controller should be hidden by
// the split view controller in a given orientation.
// (This method is only called on the leftmost view controller
// and only discriminates portrait from landscape.)
- (BOOL)splitViewController: (UISplitViewController*)svc
shouldHideViewController:(UIViewController *)vc
inOrientation:(UIInterfaceOrientation)orientation;
@end
那么 - 我该怎么办?
答案 0 :(得分:3)
我读了很多东西,实际上现在找到了正确的方法。转到detailViewController
。您的detailViewController
应该有UISplitViewControllerDelegate
。只需将此代码放入:
- (BOOL)splitViewController:(UISplitViewController *)svc shouldHideViewController:(UIViewController *)vc inOrientation:(UIInterfaceOrientation)orientation{
return NO;
}
这将使所有视图保持原位。请让我知道这对你有没有用。