0

// ViewController.m

1: - (IBAction)doNE:(id)sender {
2:
3:     [self.view removeFromSuperview];
4:     [self.view addSubView:MasterViewController];
4: }

Error on line 4: "Unexpected interface name MasterViewController :expected expression". I have two view controllers: ViewController and MasterViewController. I've set it up so that the first view is a ViewController but I'm trying to get a button to change the view.

Spontifixus
  • 6,570
  • 9
  • 45
  • 63
  • 1
    first clear what you want to do ? want to dismiss (remove) the view Controller. ? – Buntylm Mar 18 '13 at 09:00
  • There are two screens, I want to switch from the start screen to the second screen. The project is a phone book, the first screen is the contact edit/create screen, the second screen is a tableview with the list of contacts. – timeshift117 Mar 18 '13 at 09:01
  • So you want to move first ViewController to MasterViewController. – Buntylm Mar 18 '13 at 09:03
  • I'm knew to this, so I'm not entirely sure of the technicality, but I'm just trying to change screen after I press a button – timeshift117 Mar 18 '13 at 09:04
  • if you want to move from One View Controller to another try this.http://stackoverflow.com/questions/910994/view-controllers-how-to-switch-between-views-programmatically – Buntylm Mar 18 '13 at 09:05
  • It look like you are missing basic. so is you want to learn got to http://developer.apple.com/library/ios/#featuredarticles/ViewControllerPGforiPhoneOS/Introduction/Introduction.html – CRDave Mar 18 '13 at 09:08

2 Answers2

1
MasterViewController *obj = [MasterViewController alloc]init];
self.navigationController pushViewController:obj animated:YES];

you can use this code snippet .This will push a new view controller. and will give u a back button functionality to go to previous view controller.

Kasaname
  • 1,491
  • 11
  • 15
0

You Can Move First OneViewController to AnotherViewController using this.

- (IBAction)buttonPressed:(id)sender {
    MasterViewController *createUserController = [[MasterViewController alloc] initWithNibName:@"MasterViewController" bundle:[NSBundle mainBundle] keyWrapper:keyChainWrapper];
    [self presentViewController:createUserController animated:YES completion:nil];
}

And if you Using UINavigationViewController you can push the ViewController like

[self.navigationController pushViewController:createUserController  animated:YES];

and back using

[self.navigationController popViewController:createUserController animated:YES];
Buntylm
  • 7,345
  • 1
  • 31
  • 51