如何以编程方式隐藏 UISplitViewController 的主部分?
问题描述:
在我的 UISplitViewController 中,当用户单击横向按钮时,我希望视图的主"部分隐藏自身,而细节"部分接管全屏.同样,再次单击该按钮会使用户返回标准的分屏视图.是否可以使用内置类来做到这一点?
In my UISplitViewController, I want the "master" part of the view to hide itself and the "detail" part take over the full screen when the user clicks a button in landscape. Likewise, clicking the button again takes the user back the standard, split screen view. Is it possible to do this with the built-in class?
答
iOS5 中有一个方法可以从 UISplitViewControllerDelegate 实现:
There's a method you can implement from UISplitViewControllerDelegate in iOS5:
- (BOOL)splitViewController:(UISplitViewController*)svc
shouldHideViewController:(UIViewController *)vc
inOrientation:(UIInterfaceOrientation)orientation
{
return YES;
}
MGSplitViewController 为 ios5 之前的工作内置了该功能.
MGSplitViewController has that functionality built in for pre-ios5 work.