【问题标题】:Master Detail in iPad StoryboardiPad 故事板中的主细节
【发布时间】:2013-04-16 21:15:05
【问题描述】:

我在主细节方面遇到问题我知道 masterDetail 需要成为情节提要中的初始 ViewController 并且我想在按下按钮时制作一个 MENU 我加载了MasterDetail... 我到目前为止所尝试的:

我将MENU ViewController 放在storyBoard 中,例如MENU.storyboard MasterDetail viewController 在另一个名为 MainStory.storyboard 的 StoryBoard 中 然后从构建阶段我选择storyBoard的主要条目是MENU 最后在MENU 类(例如MenuClass.m)中为按钮添加操作

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStory" bundle:nil];
MyNewViewController *myVC = [storyboard instantiateViewControllerWithIdentifier:@"myViewCont"];

然后添加这个视图。

问题是:当我在 iphone StoryBoard 中执行此步骤时,它可以完美运行。 但是,当我在 iPad StoryBoard 中执行相同的简单步骤时,代码崩溃(甚至在 MENU storyBoard 中显示之前)...... 当我在

中评论代码时
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions     ->appDelegate

菜单 StoryBoard 出现,但是当按下按钮加载 MasterDetail 时我遇到了崩溃 当然是因为我在appDelegate中注释了MasterDetail初始化代码。

【问题讨论】:

    标签: ios


    【解决方案1】:

    我认为只使用 1 个故事板并将您的菜单 ViewController 设置为应用程序的 rootViewController 会更容易。然后将菜单 ViewController 链接到 NavigationController 以模态 segue 通向 Master Detail 视图。

    【讨论】:

    • 我完全按照你说的那样崩溃,并出现同样的错误“由于未捕获的异常'NSInvalidArgumentException'而终止应用程序,原因:'-[UIViewController topViewController]:无法识别的选择器发送到实例 0x8131380'”
    • 在 iPad StoryBoard 而非 iPhone StoryBoard 中尝试
    • 刚看到SplitViewController,我查看了文档,上面写着:"you must always install the view from a UISplitViewController object as the root view of your application’s window. [...] Split view controllers cannot be presented modally."。所以2故事板似乎是唯一的方法,但我不知道该怎么做对不起。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-10-06
    • 2015-09-20
    • 2013-11-16
    • 2023-03-04
    • 1970-01-01
    • 2013-05-12
    • 1970-01-01
    相关资源
    最近更新 更多