我已经实现了一个 UISpliview 并且效果很好。但是我想为用户添加一个选项,通过按下主视图中的按钮来关闭主视图(因此它会执行相同的操作,这是通过触摸详细视图来欺骗的)。这可能吗?我已经更新了代码,我认为它应该可以工作,但它什么也没做?
- (void)splitViewController:(UISplitViewController *)splitController willHideViewController:(UIViewController *)viewController withBarButtonItem:(UIBarButtonItem *)barButtonItem forPopoverController:(UIPopoverController *)popoverController
{
barButtonItem = _backButton;
[self.navigationItem setLeftBarButtonItem:barButtonItem animated:YES];
self.masterPopoverController = popoverController;
}
- (void)splitViewController:(UISplitViewController *)splitController willShowViewController: (UIViewController *)viewController invalidatingBarButtonItem:(UIBarButtonItem *)barButtonItem
{
// Called when the view is shown again in the split view, invalidating the button and popover controller.
[self.navigationItem setLeftBarButtonItem:nil animated:YES];
self.masterPopoverController = nil;
}
//the action, which gets called once the button is pressed.
- (IBAction)backToFullDetailView:(id)sender
{
[self.masterPopoverController dismissPopoverAnimated:YES];
}