0

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?

0

2 Answers 2

5

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)
Sign up to request clarification or add additional context in comments.

3 Comments

'_??' is not convertible to 'Void'
The code worked fine for me. Are you using Xcode 7 and Swift 2? Or perhaps there is an error somewhere else in your code.
The code i posted is written in Swift 2. You should consider upgrading to Xcode 7 and converting your project to Swift 2.
0

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)

3 Comments

'AnyObject!' is not convertible to 'HomeSummaryViewController'
just add "as! HomeSummaryViewController" to the end of the second line. I also edited my answer
Not handling Optionals is a bad idea.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.