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

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

(截圖換了一個(gè)項(xiàng)目名, 不要在意這些細(xì)節(jié).)
用上自己的ViewController
在ViewController里寫(xiě)上自己的完美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沒(méi)有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開(kāi)發(fā)刪除storyboard步驟詳解的詳細(xì)內(nèi)容,更多關(guān)于iOS刪除storyboard步驟的資料請(qǐng)關(guān)注腳本之家其它相關(guān)文章!
相關(guān)文章
IOS初始化控制器的實(shí)現(xiàn)方法總結(jié)
這篇文章主要介紹了IOS初始化控制器的實(shí)現(xiàn)方法總結(jié)的相關(guān)資料,這里提供兩種實(shí)現(xiàn)方法分別是ViewControllViewController方法和 ViewControllViewController 與 xib方法,需要的朋友可以參考下2017-10-10
詳解iOS AFNetworking取消正在進(jìn)行的網(wǎng)絡(luò)請(qǐng)求
這篇文章主要介紹了詳解iOS AFNetworking取消正在進(jìn)行的網(wǎng)絡(luò)請(qǐng)求,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2018-06-06
iOS自定義UIBarButtonItem的target和action示例代碼
這篇文章主要給大家介紹了關(guān)于iOS自定義UIBarButtonItem的target和action的相關(guān)資料,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2019-02-02
IOS實(shí)現(xiàn)碎片化動(dòng)畫(huà)詳解
在網(wǎng)上看到一個(gè)驚艷的碎片化動(dòng)畫(huà),于是實(shí)現(xiàn)之后拿來(lái)講解一下,有需要的小伙伴們可以參考學(xué)習(xí)哦。2016-08-08
iOS應(yīng)用開(kāi)發(fā)中使用UIScrollView控件來(lái)實(shí)現(xiàn)圖片縮放
這篇文章主要介紹了iOS開(kāi)發(fā)中使用UIScrollView控件來(lái)實(shí)現(xiàn)圖片縮放的方法,代碼基于傳統(tǒng)的Objective-C,需要的朋友可以參考下2015-12-12
iOS 基于AFNetworking下自簽名證書(shū)配置的方法
本篇文章主要介紹了iOS 基于AFNetworking下自簽名證書(shū)配置的方法,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2018-03-03

