gpt4 book ai didi

ios - 在 SplitViewController 中从 DetailViewController 隐藏 MasterViewController

转载 作者:行者123 更新时间:2023-11-28 21:44:43 26 4
gpt4 key购买 nike

我有一个 SplitViewController 设置有一个 DetailViewController 和一个 MasterViewController。 DetailViewController 包含一个 map ,我想在 map 上放置一个按钮,用于折叠和展开 MasterViewController。在 Apple 的 App Store 应用程序中就像这样:

enter image description here

点击按钮然后给出:

enter image description here

关于如何实现类似效果的任何想法?注意我不想关闭顶部工具栏,只是 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];
}];

最佳答案

隐藏主视图

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];
}];

希望对你有用!

关于ios - 在 SplitViewController 中从 DetailViewController 隐藏 MasterViewController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30657880/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com