我的故事板splitview应用程序出了问题。我有这个弹出控制器,但是当我按下条形按钮项而不是弹出屏幕顶部时,它会从侧面被推动。有什么想法吗?
- (void)splitViewController:(UISplitViewController *)splitController willHideViewController:(UIViewController *)viewController withBarButtonItem:(UIBarButtonItem *)barButtonItem forPopoverController:(UIPopoverController *)popoverController
{
barButtonItem.title = NSLocalizedString(@"Master", @"Master");
[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:barButtonItem animated:YES];
self.popoverController =nil;
// self.masterPopoverController = ;
}
答案 0 :(得分:0)
你可以尝试一下这个:
- (void)splitViewController: (UISplitViewController*)splitController willHideViewController:(UIViewController *)viewController withBarButtonItem:(UIBarButtonItem*)barButtonItem forPopoverController:(UIPopoverController*)popoverController {
barButtonItem.title = NSLocalizedString(@"Master", @"Master");
NSMutableArray *items = [[_toolbar items] mutableCopy];
[items insertObject:barButtonItem atIndex:0];
[_toolbar setItems:items animated:YES];
[items release];
self.popover = popoverController;
}
- (void)splitViewController: (UISplitViewController*)splitController willShowViewController:(UIViewController *)viewController invalidatingBarButtonItem:(UIBarButtonItem *)barButtonItem {
NSMutableArray *items = [[_toolbar items] mutableCopy];
[items removeObjectAtIndex:0];
[_toolbar setItems:items animated:YES];
[items release];
self.popover = nil;
}