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)容,更多關(guān)于iOS刪除storyboard步驟的資料請關(guān)注腳本之家其它相關(guān)文章!
相關(guān)文章
iOS獲取當前設備型號等信息(全)包含iPhone7和iPhone7P
這篇文章主要介紹了iOS獲取當前設備型號設備信息的總結(jié)包含iPhone7和iPhone7P,包括ios7之前之后的獲取方式,本文接的非常詳細,具有參考借鑒價值,需要的朋友可以參考下2016-10-10
iOS實現(xiàn)列表與網(wǎng)格兩種視圖的相互切換
相信大家應該也都發(fā)現(xiàn)了,在現(xiàn)在很多的電商app中,都會有列表視圖和網(wǎng)格兩種視圖的相互切換。例如京東和淘寶。這樣更利于提高用戶的體驗度,所以這篇文章小編就是大家分享下利用iOS實現(xiàn)列表與網(wǎng)格兩種視圖相互切換的方法,文中介紹的很詳細,感興趣的下面來一起看看吧。2016-10-10
iOS開發(fā)之使用Storyboard預覽UI在不同屏幕上的運行效果
使用Storyboard做開發(fā)效率非常高,為了防止在團隊中發(fā)生沖突,采取的解決辦法是負責UI開發(fā)的同事最好每人維護一個Storyboard, 公用的組件使用輕量級的xib或者純代碼來實現(xiàn),下面小編就給大家介紹如何使用Storyboard預覽UI在不同屏幕上的運行效果,需要的朋友可以參考下2015-08-08

