300字范文,内容丰富有趣,生活中的好帮手!
300字范文 > iOS storyboard 与 xib 间相互跳转

iOS storyboard 与 xib 间相互跳转

时间:2023-09-23 08:59:20

相关推荐

iOS storyboard 与 xib 间相互跳转

项目结构

storyboard 跳转到 xib

restaurantViewController *vc = [[restaurantViewController alloc] initWithNibName:@"restaurantViewController" bundle:[NSBundle mainBundle]];[self presentViewController:vc animated:YES completion:^{NSLog(@"进入");}];

xib 跳转到 storyboard

UIStoryboard *sb = [UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle]];ViewController *vc = [sb instantiateViewControllerWithIdentifier:@"main"];[self presentViewController:vc animated:YES completion:^{NSLog(@"退回");}];

注意:

[UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle]]; 代码中的Mainstoryboard文件的名字。

ViewController *vc = [sb instantiateViewControllerWithIdentifier:@"main"]; 代码中mainStoryboard ID,如何设置呢,点击要跳转的 storyboard 文件,如下图操作

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。