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的跳转事件不能用代码来写吗
IOSswift 界面跳转会黑屏
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
2条回答
- sun_ljz 2015-07-13 09:58关注
用这种方式读取
let sb = UIStoryboard.init(name:"Main",bundle:NSBundle.mainBundle()) let viewCro = sb.instantiateViewControllerWithIdentifier("InfoViewController")
Main 指的是你StoryBoard文件的名称
InfoViewController 这里替换成你控制器的在StoryBoard中的id
设置id的地方在这里本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 1无用