gpt4 book ai didi

ios - 缺少 "master"按钮和滑动手势不起作用 master/detail ios

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:38:25 26 4
gpt4 key购买 nike

我创建了主细节应用程序,其中包含多个细节 View Controller ,通过替换 segue 连接到 Split View。在横向上一切正常,但在纵向上我缺少打开主 TableView 的按钮并且在屏幕左侧滑动不起作用并且无法打开应用程序的主端。

编辑:

在我的 DetailViewController 中,我有两种方法,与 xcode 为主从应用程序提供的模板相同:

#pragma mark - Split view

- (void)splitViewController:(UISplitViewController *)splitController willHideViewController:(UIViewController *)viewController withBarButtonItem:(UIBarButtonItem *)barButtonItem forPopoverController:(UIPopoverController *)popoverController
{
barButtonItem.title = NSLocalizedString(@"MasterButton", @"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:nil animated:YES];
self.masterPopoverController = nil;
}

编辑 2:在更改我的 detailViewController 时,我也更改了委托(delegate)。

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
UIViewController *destinationViewController = [segue destinationViewController];
if ([destinationViewController conformsToProtocol:@protocol(UISplitViewControllerDelegate)]) {
self.splitViewController.delegate = (id)destinationViewController;
}
else {
self.splitViewController.delegate = nil;
}
}

编辑 3:我最终通过在我创建的每个 DetailViewController 中添加这行代码解决了我的问题:

self.splitViewController.delegate = self;

最佳答案

你需要放置 barButtonItem 来自

- (void)splitViewController:(UISplitViewController *)svc willHideViewController:(UIViewController *)aViewController withBarButtonItem:(UIBarButtonItem *)barButtonItem forPopoverController:(UIPopoverController *)pc

在详细 View Controller 的导航栏上。

关于ios - 缺少 "master"按钮和滑动手势不起作用 master/detail ios,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20188486/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com