呈现ViewController只是显示黑屏
我正在尝试通过按钮操作介绍一个ViewController。但这似乎无法正常工作。我没有任何错误,但是在单击按钮后,屏幕变黑了,什么也不会发生。我唯一能找到的东西是针对Objective-C,我只是想学习Swift。我正在使用故事板来设计它,并在设计器代码中适当的位置添加了ViewController
:
@IBAction func doShow(_ sender: Any)
{
var newWindowViewController = NewWindowViewController()
newWindowViewController.baseItem = self.baseItem
present(newWindowViewController, animated: false)
}
I am trying to present a ViewController from a Button action. But this seems to not work as i want it to. I do not get any error but after clicking the button the screen turns black and nothing happens. The only things i could manage to find are for objective-c and i am just trying to learn Swift. I am using storyboard to design this and added the Viewcontroller in the appropriate place in the designer
Code:
@IBAction func doShow(_ sender: Any)
{
var newWindowViewController = NewWindowViewController()
newWindowViewController.baseItem = self.baseItem
present(newWindowViewController, animated: false)
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要先从故事板上实例化视图控制器。否则,它将不会包含任何视图并将黑色变。
You need to instantiate the ViewController first from your storyboard. Else it won´t contain any View and turn up black.