我有一个带按钮的Xib文件.单击按钮时,我想要转到另一个视图控制器.我在StoryBoard中的视图控制器之间创建了一个segue并创建了一个标识符,但似乎无法以编程方式调用它.
@IBAction func buttonAction(sender: UIButton) { self.performSegueWithIdentifier("SegueToPostDetail",sender: sender) }
Xcode错误是“….没有成员’performSequeWithIdentifier’
谢谢!
解决方法
您不能在Xib类中调用performSegueWithIdentifier,只能在UIViewController类中调用.所以你有2个解决方案:
>在UIViewController中按下按钮,单击该按钮调用performSegueWithIdentifier.
>在Xib类中创建委托,UIViewController类实现该委托协议. How do I set up a simple delegate to communicate between two view controllers?