xcode – 执行从Xib到ViewContoller的segue

前端之家收集整理的这篇文章主要介绍了xcode – 执行从Xib到ViewContoller的segue前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我有一个带按钮的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?

猜你在找的Xcode相关文章