iOS開發(fā)刪除storyboard步驟詳解
刪除iOS項(xiàng)目中的storyboard
刪除項(xiàng)目中的storyboard, (變成一個純代碼的iOS UIKit項(xiàng)目), 需要幾步?
- 找到storyboard, 刪掉它.
- 直接用ViewController.
刪除storyboard
- 首先, 你得有(新建)一個storyboard項(xiàng)目.
- 刪除storyboard. 選"Move to Trash".
- 刪除plist中的storyboard name.

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

(截圖換了一個項(xiàng)目名, 不要在意這些細(xì)節(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.
}
}
設(shè)置新的rootViewController.
- 在
SceneDelegate中設(shè)置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
}
...
運(yùn)行程序, 看到自己在ViewController里設(shè)置的View.
以上就是iOS開發(fā)刪除storyboard步驟詳解的詳細(xì)內(nèi)容,更多關(guān)于iOS刪除storyboard步驟的資料請關(guān)注腳本之家其它相關(guān)文章!
相關(guān)文章
iOS實(shí)現(xiàn)動態(tài)元素的引導(dǎo)圖效果
這篇文章給大家介紹了iOS實(shí)現(xiàn)動態(tài)元素的引導(dǎo)圖效果的步驟,文章給出了示例代碼介紹的很詳細(xì),有需要的朋友們可以參考借鑒,下面來一起看看吧。2016-09-09
iOS 對當(dāng)前webView進(jìn)行截屏的方法
下面小編就為大家?guī)硪黄猧OS 對當(dāng)前webView進(jìn)行截屏的方法。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2017-04-04
iOS獲取當(dāng)前設(shè)備型號等信息(全)包含iPhone7和iPhone7P
這篇文章主要介紹了iOS獲取當(dāng)前設(shè)備型號設(shè)備信息的總結(jié)包含iPhone7和iPhone7P,包括ios7之前之后的獲取方式,本文接的非常詳細(xì),具有參考借鑒價值,需要的朋友可以參考下2016-10-10
iOS實(shí)現(xiàn)列表與網(wǎng)格兩種視圖的相互切換
相信大家應(yīng)該也都發(fā)現(xiàn)了,在現(xiàn)在很多的電商app中,都會有列表視圖和網(wǎng)格兩種視圖的相互切換。例如京東和淘寶。這樣更利于提高用戶的體驗(yàn)度,所以這篇文章小編就是大家分享下利用iOS實(shí)現(xiàn)列表與網(wǎng)格兩種視圖相互切換的方法,文中介紹的很詳細(xì),感興趣的下面來一起看看吧。2016-10-10
iOS開發(fā)之使用Storyboard預(yù)覽UI在不同屏幕上的運(yùn)行效果
使用Storyboard做開發(fā)效率非常高,為了防止在團(tuán)隊(duì)中發(fā)生沖突,采取的解決辦法是負(fù)責(zé)UI開發(fā)的同事最好每人維護(hù)一個Storyboard, 公用的組件使用輕量級的xib或者純代碼來實(shí)現(xiàn),下面小編就給大家介紹如何使用Storyboard預(yù)覽UI在不同屏幕上的運(yùn)行效果,需要的朋友可以參考下2015-08-08

