iOS開發(fā)刪除storyboard步驟詳解
更新時間:2022年11月07日 11:22:49 作者:圣騎士Wind
這篇文章主要為大家介紹了iOS系列學習之刪除storyboard步驟詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪
刪除iOS項目中的storyboard
刪除項目中的storyboard, (變成一個純代碼的iOS UIKit項目), 需要幾步?
- 找到storyboard, 刪掉它.
- 直接用ViewController.
刪除storyboard
- 首先, 你得有(新建)一個storyboard項目.
- 刪除storyboard. 選"Move to Trash".
- 刪除plist中的storyboard name.

- 刪除deploy target中的Main Interface, 本來是”main”, 把它變?yōu)榭?

(截圖換了一個項目名, 不要在意這些細節(jié).)
用上自己的ViewController
在ViewController里寫上自己的完美View. 比如:
import UIKit
class ViewController: UIViewController {
override func loadView() {
view = UIView()
view.backgroundColor = .systemBlue
}
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
}
設置新的rootViewController.
- 在
SceneDelegate中設置rootViewController. (iOS 13)
class SceneDelegate: UIResponder, UIWindowSceneDelegate {
var window: UIWindow?
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
// Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.
// If using a storyboard, the `window` property will automatically be initialized and attached to the scene.
// This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).
guard let windowScene = (scene as? UIWindowScene) else { return }
let window = UIWindow(windowScene: windowScene)
window.rootViewController = ViewController()
self.window = window
window.makeKeyAndVisible()
}
...
- tvOS沒有SceneDelegate (或者你想要兼容iOS 13以前的舊版本):
import UIKit
@main
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_: UIApplication, didFinishLaunchingWithOptions _: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
window = UIWindow(frame: UIScreen.main.bounds)
window?.rootViewController = ViewController()
window?.makeKeyAndVisible()
return true
}
...
運行程序, 看到自己在ViewController里設置的View.
以上就是iOS開發(fā)刪除storyboard步驟詳解的詳細內(nèi)容,更多關于iOS刪除storyboard步驟的資料請關注腳本之家其它相關文章!
相關文章
詳解iOS AFNetworking取消正在進行的網(wǎng)絡請求
這篇文章主要介紹了詳解iOS AFNetworking取消正在進行的網(wǎng)絡請求,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2018-06-06
iOS自定義UIBarButtonItem的target和action示例代碼
這篇文章主要給大家介紹了關于iOS自定義UIBarButtonItem的target和action的相關資料,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面來一起學習學習吧2019-02-02
iOS應用開發(fā)中使用UIScrollView控件來實現(xiàn)圖片縮放
這篇文章主要介紹了iOS開發(fā)中使用UIScrollView控件來實現(xiàn)圖片縮放的方法,代碼基于傳統(tǒng)的Objective-C,需要的朋友可以參考下2015-12-12

