gpt4 book ai didi

ios - UISplitViewController 一致分隔线

转载 作者:行者123 更新时间:2023-12-01 19:06:00 24 4
gpt4 key购买 nike

在我的 iPad 应用程序中,我使用带有两个 UINavigationControllers 作为主控和细节的 UISplitViewController。在 Potrait 中,我希望通过 UIPopoverViewController 隐藏和访问主控。这是我的 UISplitViewController 子类的实现,它工作正常:

- (id)init {
self = [super init];
if (self) {
_splitViewController = [[UISplitViewController alloc] init];
_splitViewController.delegate = self;

_searchViewController = [[UIViewController alloc] init];
_searchViewController.view.backgroundColor = [UIColor whiteColor];
_masterNavController = [[UINavigationController alloc] initWithRootViewController:_searchViewController];
_masterNavController.navigationBar.translucent = NO;

_mapViewController = [[MapViewController_iPad alloc] init];
_detailNavController = [[UINavigationController alloc] initWithRootViewController:_mapViewController];
_detailNavController.navigationBar.translucent = NO;

_splitViewController.viewControllers = @[_masterNavController, _detailNavController];
_splitViewController.view.backgroundColor = [UIColor redColor];
}

return self;
}

#pragma mark -
#pragma mark - UISplitViewControllerDelegate

- (void)splitViewController:(UISplitViewController *)svc willHideViewController:(UIViewController *)aViewController withBarButtonItem:(UIBarButtonItem *)barButtonItem forPopoverController:(UIPopoverController *)pc {
svc.view.backgroundColor = [UIColor redColor];
barButtonItem.title = NSLocalizedString(@"ipad_search_vc_bar_button_title", @"Name of the master view controller button on iPad");
[self.mapViewController.navigationItem setLeftBarButtonItem:barButtonItem animated:YES];
}

- (void)splitViewController:(UISplitViewController *)svc willShowViewController:(UIViewController *)aViewController invalidatingBarButtonItem:(UIBarButtonItem *)barButtonItem {
svc.view.backgroundColor = [UIColor redColor];
[self.mapViewController.navigationItem setLeftBarButtonItem:nil animated:YES];
}

- (void)splitViewController:(UISplitViewController *)svc popoverController:(UIPopoverController *)pc willPresentViewController:(UIViewController *)aViewController {
svc.view.backgroundColor = [UIColor redColor];
[pc setPopoverBackgroundViewClass:[CustomPopoverBackgroundView class]];
}

这是它的外观:

enter image description here

第一次启动 App 并点击 UIBarButton 后,master 如下所示:

enter image description here

在第二次隐藏并点击 UIBarButton 项目后,主人看起来应该这样做。它有红色分隔线,而不是标准的彩色分隔线:

enter image description here

现在,在 UISplitViewController 委托(delegate)中使用的 CustomBackgroundView 实际上正在被实例化,但不知何故第一次没有使用。

知道如何强制 UIPopOverController 第一次使用 CustomBackgroundView 吗?

最佳答案

我最终只是简单地向 UISplitViewController 的 View 添加了一个 subview ,它与 UINavigationBar 具有相同的颜色。

UISplitViewController *splitViewController = [[UISplitViewController alloc] init];
[splitViewController.view addSubview:coloredView];

关于ios - UISplitViewController 一致分隔线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19593407/

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