在master splitview中从uibarbutton中解除master splitview

时间:2012-09-16 13:52:07

标签: objective-c ios xcode

我实施了一个UISpliview,效果很好。但是我想为用户添加一个选项,通过按下masterview中的按钮来关闭masterview(因此它将执行相同的操作,通过触摸detailview来进行trickered)。这可能吗?我用代码更新了,我相信它应该可行,但是它没有做任何事情?

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

Masterview shown with button (help)

1 个答案:

答案 0 :(得分:0)

我相信你需要解雇你的popover。有人提出了类似的问题here。您正在查看类似[youPopoverController dismissPopoverAnimated: YES];

的内容