我有一个UISplitViewController,我想始终显示iPad的主视图和详细视图控制器。这条线为我照顾:
// Always display master and detail in large screens
self.preferredDisplayMode = UISplitViewControllerDisplayMode.AllVisible
在prepareForSegue中,当打开详细视图控制器时,后面的按钮有以下几行代码
controller.navigationItem.leftBarButtonItem = self.splitViewController?.displayModeButtonItem()
controller.navigationItem.leftItemsSupplementBackButton = true
现在当用户按下该后退按钮时,我想在隐藏主视图控制器后执行操作。我没有找到如何做到这一点的运气。在SplitViewControllerDelegate中,我尝试使用:
func splitViewController(svc: UISplitViewController, willChangeToDisplayMode displayMode: UISplitViewControllerDisplayMode)
但是在Detail视图控制器变为全屏之前调用该函数。当UISplitViewController完成隐藏主视图时,是否有我可以做的功能或其他帮助通知我?
答案 0 :(得分:0)
您可以在DetailViewController中的视图上添加观察者,并在触发时执行特定操作:
ChatVC *chatVC = [self.storyboard instantiateViewControllerWithIdentifier:@"chat"];
PrivateChatController * privateChatController = [self.storyboard instantiateViewControllerWithIdentifier:@"privatechat"];
[self.navigationController pushViewController:privateChatController animated:YES];
NSMutableArray *viewControllers = [self.navigationController.viewControllers mutableCopy];
[viewControllers insertObject:chatVC atIndex:viewControllers.count - 2];
self.navigationController.viewControllers = viewControllers;
答案 1 :(得分:0)
您可以尝试使用delegate
方法
- (UISplitViewControllerDisplayMode)targetDisplayModeForActionInSplitViewController:(UISplitViewController *)svc;