从故事板加载场景

时间:2017-01-14 01:34:17

标签: ios swift xcode-storyboard

我正在尝试使用下面的代码启动我在故事板中创建的视图控制器,但是我的app委托文件的第一行有libc++abi.dylib: terminating with uncaught exception of type NSExceptionThread 1: Signal SIGABRT

func PostBtnAction(_ sender: AnyObject) {
    let storyboard = UIStoryboard(name: "Main", bundle: nil)
    let viewController = storyboard.instantiateViewController(withIdentifier :"PostView")
    self.present(viewController, animated: true)
}

我将自定义类设置为PostViewController,并将故事板ID设置为PostView

使用下面的代码加载场景会启动一个视图,但会给我一个黑屏。

func PostBtnAction(_ sender: AnyObject) {
    let secondViewController:PostViewController = PostViewController()
    self.present(secondViewController, animated: true, completion: nil)
}

0 个答案:

没有答案
相关问题