0

I have a table view and i put a ToolBar button so when button is clicked open a Map View. When I click the button my application crash, so I tried this:

 MapViewController *mvc = [[MapViewController alloc]initWithNibName:@"MapViewController" bundle:nil];

 // NSArray *categories = nil;
    switch ([indexPath row]){
     case 0:
       [self.navigationController pushViewController:svc animated:YES];  
       ....

And when I tap a corresponding cell it open new view and my mapView is working like a charm But when I put same in the Button action method my application crash.

Any ideas?

2
  • 1
    Can you show how you implemented the action method? Jun 14, 2011 at 12:37
  • - (void) pressButton1:(id)sender{ MapViewController *mvc = [[MapViewController alloc]initWithNibName:@"MapViewController" bundle:nil]; [self.navigationController pushViewController:mvc animated:YES];} // The crash Log: buttonPressed:]: unrecognized selector sent to instance 0x5853470 2011-06-14 15:11:14.374 TattooShops[16644:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[MonteraController buttonPressed:]: unrecognized selector sent to instance 0x5853470' terminate called after throwing an instance of 'NSException'
    – ALEX
    Jun 14, 2011 at 13:22

1 Answer 1

1

My guess is that you pass the wrong selector when you connect the button to the action.

If you have created the button programattically.

  1. Don't forget to add it to the view.
  2. The selector should look something like this: `[button addTarget:self action:@selector(pressButton1:) forControlEvents:UIControlEventTouchUpInside];

Note the : in pressButton1:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.