开发者社区 问答 正文

关于IOSswift 界面跳转会黑屏

iOS swift 用storyboard拖出的控件,给控件添加跳转事件,跳转会出现黑屏。例如

 @IBAction func ChangePassWord(sender: UIButton) {
 var vc=ChangePassWordViewController()
 self.presentViewController(vc, animated: true, completion: nil)
 }
 如果控件是用代码写的,给按钮添加这个跳转事件时可以的成功跳转的。例如
 func ChangePassWord(sender: UIButton) {
 var vc=ChangePassWordViewController()
 self.presentViewController(vc, animated: true, completion: nil)
 }

这是因为什么呢?storyboard的跳转事件不能用代码来写吗

展开
收起
爵霸 2016-03-13 08:45:51 3731 分享 版权
1 条回答
写回答
取消 提交回答
  • 用这种方式读取

     let sb = UIStoryboard.init(name:"Main",bundle:NSBundle.mainBundle())
                        let viewCro = sb.instantiateViewControllerWithIdentifier("InfoViewController")

    Main 指的是你StoryBoard文件的名称
    InfoViewController 这里替换成你控制器的在StoryBoard中的id
    设置id的地方在这里

    screenshot

    2019-07-17 19:01:38
    赞同 展开评论
问答分类:
问答地址: