【发布时间】:2018-01-19 01:30:54
【问题描述】:
我在一个类中使用以下内容来调用 UIViewController。 UIViewController 加载,但加载后变得无响应。
let storyboard : UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let homeC = storyboard.instantiateViewController(withIdentifier:
"ViewJoeProfileController") as? ViewJoeProfileController
if homeC != nil {
homeC!.view.frame = (self.window!.frame)
self.window!.addSubview(homeC!.view)
self.window!.bringSubview(toFront: homeC!.view)
}
}
任何让 UIViewController 响应加载的建议都会有帮助!
【问题讨论】:
-
你为什么用window?如果你想从另一个视图控制器中显示一个视图控制器,你可以简单地执行这个函数
present(VC, animated: true: completion: nil), developer.apple.com/documentation/uikit/uiviewcontroller/… -
检查这个
Each window typically has a single root view object (managed by a corresponding view controller) that contains all of the other views representing your content. Using a single root view simplifies the process它来自苹果!!。我觉得你做错了什么。 developer.apple.com/library/content/documentation/WindowsViews/… -
因此,如果您想推送/弹出
VC,您可能会从另一个VC, navigationController or TabbarController执行此操作...您可能不需要处理窗口,除非您设置@987654328 @
标签: ios swift uiview viewcontroller