ios - 如何在带有 Storyboard 的 UITabBarController 中实现 UISplitview?

标签 ios xcode uitableview uisplitviewcontroller uisplitviewdelegate

我一直在寻找答案,但没有一个是 Storyboard。

我用过this用于创建我的 Split View的教程,它可以工作,但是以下部分:

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

当然不会工作,因为 splitview 在 tabview 中。

如何将我的 DetailViewController 设置为委托(delegate)?

最佳答案

问题是因为我将 SplitViewController 设置为委托(delegate)中的 Root View 。

我将其更改为:

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;

而且效果很好。

它也得到了苹果的认可。

关于ios - 如何在带有 Storyboard 的 UITabBarController 中实现 UISplitview?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14226334/

相关文章:

ios - UITableViewCell 子类 : in what delegate method is it appropriate to do changes to the cells layer?

ios - 自定义 UIView 子类中的 UIButton 不触发操作事件

ios - 如何在 iOS 应用程序中保存数据?

php - 使用POST在Web服务器IOS应用程序中存储用户信息

ios - fatal error : unexpectedly found nil while unwrapping an Optional value in UITableViewCell

ios - UITableView 固定部分与动态大小

ios - 这些关于 IOS 委托(delegate)的观点是否正确?是还是不是?

javascript - 如何适应高度为 :100% on iPhone 的 DIV

ios - react native xcode 10.1 "config.h"文件未找到

ios - MagicalRecord 示例应用程序无法在 Xcode 7 中编译