【问题标题】:How can i go to storyboard from xib我如何从xib转到情节提要
【发布时间】:2014-05-23 23:04:26
【问题描述】:

我在我的项目中同时使用情节提要和 xib,我想从情节提要中获取 xib 文件,但无法反转它。那么我如何从 xib 文件转到情节提要。提前谢谢。 故事板到 xib:

Dashboard1ViewController *tempView = [[Dashboard1ViewController alloc]       initWithNibName:@"Dashboard1ViewController" bundle:nil];
    tempView.passemail = [matches valueForKey:@"email"];
    [self.view addSubview:tempView.view];

它工作得很好,但是我使用了这个代码的 xib 到情节提要

UIStoryboard *sb = [UIStoryboard storyboardWithName:@"loginUI" bundle:nil];
login2ViewController *vc = [sb instantiateViewControllerWithIdentifier:@"login2"];
vc.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentViewController:vc animated:YES completion:NULL];

但它不起作用。

【问题讨论】:

标签: objective-c storyboard xcode5 xib


【解决方案1】:

nil 更改为[NSBundle mainBundle]

UIStoryboard *sb = [UIStoryboard storyboardWithName:@"loginUI" 
                                             bundle:[NSBundle mainBundle]];

【讨论】:

    【解决方案2】:

    以下方法对我有用。确保您的标识符正确

    YourViewController *urViewController = (YourViewController *)[[UIStoryboard storyboardWithName:storyboardName bundle:nil]     instantiateViewControllerWithIdentifier:@"storyboardID"];
    [self presentViewController:urViewController animated:YES completion:nil];
    

    【讨论】:

    • 你有什么错误吗?调试并查看是否创建了 ViewController 实例。还要检查您的故事板是否已添加到捆绑资源中。
    • 你提到的两个选项没有区别。
    • 在捆绑资源中添加故事板仍然应用程序崩溃
    • @mustafabesnili 只是为了理解我提到的,正如你所说我删除了
    • @karthikPrabhu 仍然无法正常工作...你能告诉我该怎么办吗?
    猜你喜欢
    • 2020-06-02
    • 2020-10-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-12-18
    • 2012-02-13
    • 2015-09-18
    • 2013-05-18
    相关资源
    最近更新 更多