-1

How do you switch between view controllers programatically in an effective manner? I am currently utilising:

ViewController *viewController = [[ViewController alloc] init];
    [self presentViewController:viewController animated:YES completion:nil];

However this does not display the items that I've inserted using the interface builder. Only the items I've inserted programatically.

I wish to do this, as I want to display a home button on each page.

6
  • 1
    [self.navigationcontroller pushviewcontroller:viewController animated:YES ]; Commented Aug 7, 2014 at 9:55
  • are you using StoryBord or XIB? Commented Aug 7, 2014 at 9:55
  • use UINavigationController Commented Aug 7, 2014 at 9:55
  • you should provide which xib u want to display Commented Aug 7, 2014 at 9:55
  • use this link this is hope ful for u stackoverflow.com/questions/20742745/… Commented Aug 7, 2014 at 9:56

1 Answer 1

6

Give your viewController identity in StoryBord

enter image description here

then into your code

UIViewController *documetController       = [storyboard instantiateViewControllerWithIdentifier:@"MXDocumentViewController"];
[self.navigationController pushViewController:reviewListController animated:YES];
Sign up to request clarification or add additional context in comments.

2 Comments

I don't have a navigation controller. Is it required?
NavigationController is a good way if your dealing with more then one viewController into application. but still you can use [self presentViewController:viewController animated:YES completion:nil];

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.