Reputation: 21
// 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.
Upvotes: 0
Views: 281
Reputation: 7373
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];
Upvotes: 0
Reputation: 1501
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.
Upvotes: 1