gpt4 book ai didi

ios - UINavigationController 和 SplitViewController

转载 作者:行者123 更新时间:2023-11-29 04:16:59 26 4
gpt4 key购买 nike

我有一个项目,我使用 NavigationController 作为 SplitViewController 的详细 View 。

因此,当应用程序出现时,两个方向的一切都很好。但是,一旦我将 View 插入导航 Controller 中,如果我处于纵向模式,“显示主视图”按钮(uisplitview delegate)就会消失,并且 uinavigationcontroller 的“后退”按钮将取代它。如果我按后退按钮弹出 View ,“显示主视图”按钮就会返回。

我的问题是,即使我已经推送了一些 View ,我如何管理我希望能够在 UINavigationBar 中显示两个按钮(“后退”、“显示主”)的事实?

最佳答案

您可以使用 UIToolbar 来完成此操作。您必须首先隐藏导航栏并将 UiToolbar 放置在 View 顶部。

现在您可以根据需要添加按钮。

UIToolbar *tools = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 20, 1036, 42)];          
tools.barStyle = UIBarStyleBlackTranslucent;
NSMutableArray* buttons = [[NSMutableArray alloc] initWithCapacity:3];

UIBarButtonItem * backButton = [[UIBarButtonItem alloc] initWithCustomView:myCustomView];
[buttons addObject:backButton];

//you can add also a spacer
UIBarButtonItem *spacer = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
[buttons addObject:spacer];

UIBarButtonItem * homeButton = [[UIBarButtonItem alloc] initWithCustomView:myCustomView];
[buttons addObject:homeButton];
[tools setItems:buttons animated:NO];

关于ios - UINavigationController 和 SplitViewController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13562233/

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