我创建了 Master detail 应用程序,其中包含多个通过替换 segue 连接到 Split View的详细 View Controller 。在横向上一切正常,但在纵向上我缺少打开主表格 View 和在屏幕左侧滑动的按钮不起作用,也没有打开应用程序的主侧。
编辑:
在我的 DetailViewController 中,我有两种方法,与 xcode 为 master-detail 应用程序提供的模板中相同:
#pragma mark - Split view
- (void)splitViewControllerUISplitViewController *)splitController willHideViewControllerUIViewController *)viewController withBarButtonItemUIBarButtonItem *)barButtonItem forPopoverControllerUIPopoverController *)popoverController
{
barButtonItem.title = NSLocalizedString(@"MasterButton", @"Master");
[self.navigationItem setLeftBarButtonItem:barButtonItem animated:YES];
self.masterPopoverController = popoverController;
}
- (void)splitViewControllerUISplitViewController *)splitController willShowViewControllerUIViewController *)viewController invalidatingBarButtonItemUIBarButtonItem *)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;
}
编辑 2:
在更改我的 detailViewController 时,我也更改了委托(delegate)。
- (void)prepareForSegueUIStoryboardSegue *)segue senderid)sender
{
UIViewController *destinationViewController = [segue destinationViewController];
if ([destinationViewController conformsToProtocolprotocol(UISplitViewControllerDelegate)]) {
self.splitViewController.delegate = (id)destinationViewController;
}
else {
self.splitViewController.delegate = nil;
}
}
编辑 3:
我终于通过在我创建的每个 DetailViewController 中添加这行代码来解决我的问题:
self.splitViewController.delegate = self;
Best Answer-推荐答案 strong>
你需要放置 barButtonItem from
- (void)splitViewControllerUISplitViewController *)svc willHideViewController:(UIViewController *)aViewController withBarButtonItem:(UIBarButtonItem *)barButtonItem forPopoverController:(UIPopoverController *)pc
在细节 View Controller 的导航栏。
关于ios - 缺少 "master"按钮和滑动手势不起作用主/详细 ios,我们在Stack Overflow上找到一个类似的问题:
https://stackoverflow.com/questions/20188486/
|