Reputation: 23
I want to call a segue in swift on the condition that all the fields of the form are filled in. I tried using the following code :
let vc = TargetViewController()
navigationController?.pushViewController(vc, animated: true )
I am not using a nib, and hence have tried to use this without the nib option. It opens a blank screen, but does not display the contents of the target view controller. Any help would be appreciated.
Upvotes: 0
Views: 196
Reputation: 2380
You should try This
if(Your Condition)
{
var View:ViewController2 = self.storyboard?.instantiateViewControllerWithIdentifier("") as ViewController2
self.navigationController?.pushViewController(View, animated: true)
}
Upvotes: 0
Reputation: 15464
There is a method on UIViewController
shouldPerformSegueWithIdentifier(_:sender:)
use this to test if segue can be performed. And If not return false
from this method.
Upvotes: 1