[英]Hide MasterViewController from DetailViewController in a SplitViewController
I have a SplitViewController set up with a DetailViewController and a MasterViewController. 我有一个设置了DetailViewController和MasterViewController的SplitViewController。 The DetailViewController contains a map and I want to place a button on the map that collapses and expands the MasterViewController.
DetailViewController包含一个地图,我想在地图上放置一个按钮,该按钮可以折叠并展开MasterViewController。 Exactly like this in Apple's App Store app:
在Apple的App Store应用中完全像这样:
Clicking on the button then gives: 点击按钮,然后给出:
Any ideas on how I can achieve a similar effect? 关于如何实现类似效果的任何想法? Note I don't want to close the top tool bar, just the MasterViewController.
注意我不想关闭顶部工具栏,只需关闭MasterViewController。 Thanks!
谢谢!
SOLUTION 解
Thanks to Pravin, my final solution in the IBAction is: 感谢Pravin,我在IBAction中的最终解决方案是:
if (self.splitViewController.preferredDisplayMode == UISplitViewControllerDisplayModePrimaryHidden) {
self.splitViewController.preferredDisplayMode = UISplitViewControllerDisplayModeAllVisible;
} else {
self.splitViewController.preferredDisplayMode = UISplitViewControllerDisplayModePrimaryHidden;
}
[UIView animateWithDuration:0.5 animations:^ {
[self.splitViewController.view layoutIfNeeded];
}];
hide master view 隐藏主视图
AppDelegate * appDelegateObj = (AppDelegate *)[UIApplication sharedApplication].delegate;
UISplitViewController * splitView = appDelegateObj.splitViewObj;
splitView.preferredDisplayMode = UISplitViewControllerDisplayModePrimaryHidden;
[UIView animateWithDuration:1.0 animations:^
{
[spv.view layoutIfNeeded];
}];
show master view
AppDelegate * appDelegateObj = (AppDelegate *)[UIApplication sharedApplication].delegate;
UISplitViewController * splitView = appDelegateObj.splitViewObj;
splitView.preferredDisplayMode = UISplitViewControllerDisplayModeAllVisible;
[UIView animateWithDuration:1.0 animations:^
{
[spv.view layoutIfNeeded];
}];
I hope it will useful for you! 希望对您有用!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.