ios-自定义Storyboard与UIViewController
生活随笔
收集整理的這篇文章主要介紹了
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];測試結果
總結
以上是生活随笔為你收集整理的ios-自定义Storyboard与UIViewController的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Windows10 应用商店打不开问题,
- 下一篇: 美国计算机转教育专业,2021年可以申请