iOS中storyboard的问题
伊谢尔伦
伊谢尔伦 2017-05-17 10:05:01
[iOS讨论组]

storyboard中设置了两个界面。

在代码中使用

[self.navigationController pushViewController:[[SCMainViewController alloc]init] animated:YES];

怎么跳转过去没有加载啊

不能再用纯代码方式去跳转了吗。。只能用segue吗

伊谢尔伦
伊谢尔伦

小伙看你根骨奇佳,潜力无限,来学PHP伐。

全部回复(5)
曾经蜡笔没有小新
 UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"xxx" bundle:nil];
 SCMainViewController *vc = [storyboard instantiateViewControllerWithIdentifier:NSStringFromClass([SCMainViewController class])];
 [self.navigationController pushViewController:vc animated:YES];
習慣沉默

可以跳转的,感觉你的 Stroyboard 上相对应的 ViewController 没有关联 Class - SCMainViewController

習慣沉默
id loadViewControllerFromStoryboard(NSString *name,NSString *identifier)
{
    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:name bundle:nil];
    UIViewController *vc = nil;
    
    if (identifier == nil)
    {
        vc = [storyboard instantiateInitialViewController];
    }
    else
    {
        vc = [storyboard instantiateViewControllerWithIdentifier:identifier];
    }
    
    if ([vc isKindOfClass:[UIViewController class]]) {
        return vc;
    }
    return nil;
}
漂亮男人

先要在storyBoard里面填好StoryBoard ID

然后使用下面的代码加载viewController:

UIViewController *listController = [[UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle]] instantiateViewControllerWithIdentifier:@"listViewController"];
高洛峰

1.绑定类

2.push

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号