Pages

Thursday, April 11, 2013

Problem with UIBarButtonItem


Im having a problem trying to get my home button UIBarButtonItem back to my initial ViewController.



I have this code within the viewDidLoad method:



//  Create a home button


UIBarButtonItem *homeButton = [[UIBarButtonItem alloc] initWithTitle:@"Home" style:UIBarButtonItemStylePlain target:self action:@selector(goHome:)];


[self.navigationItem setLeftBarButtonItem:homeButton animated:NO];



//  Go to home page


- (void) goHome {


ViewController *view1 = [[ViewController alloc]initWithNibName:@"ViewController" bundle:nil];


[self presentViewController:view1 animated:YES completion:nil];


}



When I try and invoke the function goHome by clicking the button, I get NSInvalidArgumentException



Thanks in advance 


View the original article here

0 comments:

Post a Comment