I have viewController with segue to secondViewController named "toSecond". In viewController i load customView.xib
let myCustomView = NSBundle.mainBundle().loadNibNamed("customView", owner: self, options: nil)[0]
in this customView i have button with action:
viewController().goToSecond()
in viewController i have function with this code
func goToSecond() {
self.performSegueWithIdentifier("toSecond", sender: self)
}
but when i pressed button in customView i become a error:
viewController has no segue with identifier 'toSecond'
when i call this function directly from viewController all work great!
So, how can i call performSegueWithIdentifier from my customView?
customView source code:
import UIKit
class customView: UIView {
@IBAction func ToSecondButton(sender: AnyObject) {
viewController().goToSecond() }
}
viewController source code:
import UIKit
class viewController: UIViewController {
...
let myCustomView = NSBundle.mainBundle().loadNibNamed("customView", owner: self, options: nil)[0]
self.view.addSubview(myCustomView)
func goToSecond() {
self.performSegueWithIdentifier("toSecond", sender: self)
}
...
}