views:

22

answers:

2

Hi all.

I want set my custom method "Home" with RightNavagation button how should I? My code

UIBarButtonItem *barButton = [[UIBarButtonItem alloc] initWithTitle:@"DontWorryAboutThis" style:UIBarButtonItemStylePlain target:self action:@selector(home:)];

[barButton setImage:[UIImage imageNamed:@"home_btn.png"]];
[self.navigationItem setRightBarButtonItem:barButton];

Know I want to link this method with it.

-(IBAction)home{

   MainViewController *main=[[MainViewController alloc]
                           initWithNibName:@"MainViewController" bundle:nil];
   [self.navigationController pushViewController:main animated:YES];
}

how should I Do this please help me out.

+2  A: 

Try to change

UIBarButtonItem *barButton = [[UIBarButtonItem alloc] initWithTitle:@"DontWorryAboutThis" style:UIBarButtonItemStylePlain target:self action:@selector(home:)];

in

UIBarButtonItem *barButton = [[UIBarButtonItem alloc] initWithTitle:@"DontWorryAboutThis" style:UIBarButtonItemStylePlain target:self action:@selector(home)];
MathieuF
A: 

compare your selector @selector(home:) with your action -(IBAction)home

See the missing colon in your action? Change your action to

- (IBAction)home:(id)sender
fluchtpunkt