我有一个SplitViewController设置有DetailViewController和MasterViewController。 DetailViewController包含一个地图,我想在地图上放置一个折叠和扩展MasterViewController的按钮。在Apple的App Store应用程序中完全如此:
点击按钮然后给出:
关于如何实现类似效果的任何想法?注意我不想关闭顶部工具栏,只需关闭MasterViewController。谢谢!
解
感谢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];
}];
答案 0 :(得分:2)
隐藏主视图
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];
}];
我希望它对你有用!