在呈现视图控制器时,XCode警告我:
Presenting view controllers on detached view controllers is discouraged
为什么会这样?
答案 0 :(得分:0)
当您在viewDidLoad()
上呈现UIViewcontroller时会发生这种情况,因为在此之前未加载视图并且您在那里展示了一个新的UIViewcontroller。
尝试在viewDidAppear()之后呈现另一个视图/ UIviewcontroller,如果需要,则在内部。 或者只是删除你可以使用的警告:
self.view.window?.rootViewController?.presentViewController("vc to present", animated: true, completion: nil)