Pyae Phyoe Shein
Pyae Phyoe Shein

Reputation: 13787

Move another ViewController from different storyboard in swift

In objective-C, to move another viewcontroller from different storyboard, we will use following coding to fulfil what we want.

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Customer" bundle:nil];
HomeSummaryViewController *creaccVC = [storyboard instantiateViewControllerWithIdentifier:@"HomeSummaryViewController"];
[self.navigationController pushViewController:creaccVC animated:YES];

In swift version, please help me to how to do just like Objective-C?

Upvotes: 0

Views: 2869

Answers (2)

Dejan Skledar
Dejan Skledar

Reputation: 11435

The above code in Swift looks like this:

    let storyboard: UIStoryboard = UIStoryboard(name: "Customer", bundle: nil)
    let homeView: HomeSummaryViewController = storyboard.instantiateViewControllerWithIdentifier("HomeSummaryViewController") as! HomeSummaryViewController 
    self.navigationController?.pushViewController(homeView, animated: true)

Upvotes: 0

Adam
Adam

Reputation: 26907

It's pretty much identical to the Objective-C version.

    let storyboard = UIStoryboard(name: "Customer", bundle: nil)
    let vc = storyboard.instantiateViewControllerWithIdentifier("HomeSummaryViewController")
    self.navigationController?.pushViewController(vc, animated: true)

Upvotes: 5

Related Questions