使用情节提要在主从应用程序中隐藏 MasterViewController (XCode 4.2)
我使用带有故事板的主从模板创建了新的应用程序。我想为用户提供可以在横向模式下隐藏/显示主视图控制器的便利。我在网上找到了几个例子,但没有一个使用故事板和带有导航控制器的主从模板。
我已经实现了 splitviewcontroller willHideViewController & willShowViewController 帮助我在纵向模式下隐藏主视图控制器。我在应用程序委托的 didFinishLaunchingWithOptions 方法中使用下面的代码来最初加载视图,
UISplitViewController *splitViewController = (UISplitViewController *)self.window.rootViewController;
UINavigationController *navigationController = [splitViewController.viewControllers lastObject];
splitViewController.delegate = (id)navigationController.topViewController;
如果您能给我指出正确的方向,我将不胜感激。
谢谢, 塔潘·德赛
I have created new application using Master-Detail Templte with storyboard. I want to give user facility where they can Hide/Show Master View Controller in Landscape mode. I found few examples on net but none are using story board and Master-Detail template with Navigation Controller.
I have already implemented splitviewcontroller willHideViewController & willShowViewController which help me hide Master View Controller in Portrait mode. I am using below code in didFinishLaunchingWithOptions method of App Delegate to load views intially,
UISplitViewController *splitViewController = (UISplitViewController *)self.window.rootViewController;
UINavigationController *navigationController = [splitViewController.viewControllers lastObject];
splitViewController.delegate = (id)navigationController.topViewController;
I would appriciate if you can point me right direction.
Thanks,
Tapan Desai
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
主视图显示在弹出窗口中,弹出窗口可用于控制主视图的可见性。
所以...按照以下步骤操作:
1) 创建一个属性来保存 popoverController
2) 捕获 SplitViewController willHide 委托调用上的 popoverController
3) 最后使用 pc var 关闭弹出窗口
The master view is presented in a popover and the popover can be used to control the visibility of the master.
So...follow these steps:
1) Create a property to hold the popoverController
2) Capture the popoverController on the SplitViewController willHide delegate call
3) Finally just use the pc var to dismiss the popover