我有一个项目,我使用NavigationController
作为SplitViewController
的详细视图。
因此,当应用程序显示时,两个方向的一切都很好。但是,只要我在导航控制器中按下一个视图,如果我处于纵向模式,我的“显示主视图”按钮(uisplitview委托)将会消失,而uinavigationcontroller
的“后退”按钮将取代它。如果我按后退按钮弹出我的视图,则会显示“显示主视图”按钮。
我的问题是,我如何管理我希望能够在我的UINavigationBar
中显示两个按钮('后退','显示主人')的事实,即使我已经推送了一些观点?
答案 0 :(得分:1)
您可以使用工具栏执行此操作。您必须先隐藏导航栏并将UiToolbar放在视图的顶部。
现在您可以根据需要添加按钮。
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];
答案 1 :(得分:0)
您根本不能使用常规UINavigationBar
。
您必须将“show master view”按钮放在其他位置 - 例如在详情视图底部的UIToolbar
中。
或者您可以编写自己的NavigationController和NavigationBar,但这需要更多的工作。 :)