ios-自定义Storyboard与UIViewController
作者:互联网
title: ios-自定义Storyboard与UIViewController
categories: Ios
tags: [ios, Storyboard, UIViewController]
date: 2021-02-10 15:52:42
comments: false
mathjax: true
toc: true
ios-自定义Storyboard与UIViewController
前篇
- Present storyboard ViewController from another ViewController - https://stackoverflow.com/questions/8924052/present-storyboard-viewcontroller-from-another-viewcontroller
流程
-
创建 Empty.storyboard
-
在 storyboard 里添加一个 view controller
-
-
创建 EmptyViewController 类, 用来绑定 Empty.storyboard 相关事件.
-
绑定 sotryboard 和 EmptyViewController 类, 并指定 storyboard 的 identity, 如: sid_empty
-
代码显示.
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Empty" bundle:nil]; // 不需要带 .storyboard 后缀, 否则闪退 EmptyViewController *evc = [storyboard instantiateViewControllerWithIdentifier:@"sid_empty"]; // 一定要和 storyboard 中设置的一致, 否则闪退 [[UIApplication sharedApplication].windows[0].rootViewController presentViewController:evc animated:YES completion:nil];
-
测试结果
标签:storyboard,自定义,ios,Storyboard,UIViewController,Empty 来源: https://blog.csdn.net/yangxuan0261/article/details/113784079