简体   繁体   English

如何在带故事板的UITabBarController中实现UISplitview?

[英]How do I implement a UISplitview in a UITabBarController with storyboards?

I have been searching high and low for an answer to this but none are for storyboards. 我一直在寻找这个问题的答案,但没有一个是故事板。

I have used this tutorial for creating my splitview and it works however the following part: 我已经使用教程创建了我的splitview,但它的工作原理如下:

UISplitViewController *splitViewController = (UISplitViewController *)self.window.rootViewController;
UINavigationController *navigationController = [splitViewController.viewControllers lastObject];
splitViewController.delegate = (id)navigationController.topViewController;

Won't work of course because the splitview is in a tabview. 当然不会工作,因为splitview在tabview中。

How do I set my DetailViewController as the delegate? 如何将DetailViewController设置为委托?

The problem was because I was setting the SplitViewController as the root view in the delegate. 问题是因为我将SplitViewController设置为委托中的根视图。

I changed it to: 我改成了:

UITabBarController *tabBarController = (UITabBarController *)self.window.rootViewController;
    UISplitViewController *splitViewController = [tabBarController.viewControllers lastObject];//(UISplitViewController *)self.window.rootViewController;
    UINavigationController *navigationController = [splitViewController.viewControllers lastObject];
    splitViewController.delegate = (id)navigationController.topViewController;

And it works perfectly. 而且效果很好。

It has also been approved by Apple. 它也得到了Apple的批准。

You don't. 你没有。 Split views have to be the root view controller of the window. 拆分视图必须是窗口的根视图控制器。 You can't have one embedded in a tab view controller. 您不能在选项卡视图控制器中嵌入一个。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM