如何以编程方式显示Swift ViewController
? 下面的命令可以工作,但我想展示的VC卡在
出现
出现
州政府?
第0步
class ydHiddenVC: UIViewController {
override func viewDidLoad() {
print("code executing in viewDidLoad")
}
}
在AppDelegate开始时放置断点,其中lldb设置为Swift上下文。。。
(lldb) exp let $a = ydHiddenVC()
(lldb) po $a
<DELETE_PROV_PROFILE_MACHINE.ydHiddenVC: 0x7fa9f5d00ef0>
(lldb) continue
第2步
(lldb) e id $b = (id)0x7fa9f5d00ef0 // cast the Swift VC to something Objective-C can deal with
(lldb) po [[UIWindow keyWindow] rootViewController]
<UINavigationController: 0x7fa9f783e800>
(lldb) e id $rootvc = (id)0x7fa9f783e800
(lldb) po $rootvc
<UINavigationController: 0x7fa9f783e800>
(lldb) expression (void)[$rootvc pushViewController:$b animated:YES]
(lldb) caflush
code executing in viewDidLoad
摘要
当我的ViewDidLoad代码执行时,这看起来很成功。但是,ViewController看起来并不好。在转换过程中,它被卡在了屏幕的中间。与
Chisel
pvc
命令,可以打印视图层次结构中的内容。这显示了我的问题:
(lldb) pvc
<UINavigationController 0x7fa9f783e800>, state: appeared, view: <UILayoutContainerView 0x7fa9f5d10d10>
| <DELETE_PROV_PROFILE_MACHINE.ydHomeVC 0x7fa9f5f0bc10>, state: disappearing, view: <UIView 0x7fa9f5d0e300>
| <DELETE_PROV_PROFILE_MACHINE.ydHiddenVC 0x7fa9f5d00ef0>, state: appearing, view: <UIView 0x7fa9f5d14e10>