storyboard 有三个概念是最容易混淆:
storyboard VS xib:
storyboard 注重於多个页面的层级关系及跳转
xib 注重於单个页面的布局,若多人开发同个专案,xib 比较推荐
先建专案
设定存档路径
New Group
New File
选Cocoa Touch Class
p.s: MainVC = Main ViewController
info.plist -> Application Scene Manifest -> Scene Configuration -> Application Session Role -> Item0 ( Default Configuration ) -> 删掉 Storyboard Name
选择xib档
找到 SceneDelegate.swift 下的 scene 函数
修改为此
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
guard let windowScene = (scene as? UIWindowScene) else { return }
// MARK: Without NavigationController
// let rootVC = MainVC(nibName: String(describing: MainVC.self), bundle: nil)
// MARK: With NavigationController
let rootVC = UINavigationController(rootViewController: MainVC())
window = UIWindow(frame: windowScene.coordinateSpace.bounds)
window?.windowScene = windowScene
window?.rootViewController = rootVC //navController
window?.makeKeyAndVisible()
// 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).
}
删除这两个档案
测试:
在MainVC.xib档下新增一个Lable,拉Outlet到Main.swift档下
烧到模拟器
这样就完成 Xcode 的 xib 环境建置了!明天会分享 push 、 present 转画面,敬请期待!
<<: [Day28] Flutter - Application Click Game (part12)
>>: Angular ElementRef、TemplateRef、viewContainerRef 的区别
前言 大家好我是 Andy,在休息一次的铁人赛後这次又想不开的来报名了XD 有些读者在看我以前写的文...
Youtube 频道:https://www.youtube.com/c/kaochenlong ...
上回说到歌伦比亚大学制作的类似AR眼镜的装置,今天!还是歌伦比亚大学 1996-1997年 他们在1...
嘿~~ 各位好,我是菜市场阿龙! 完结篇! 频道:https://www.youtube.com/p...
教材网址 https://coding104.blogspot.com/2021/06/java.h...