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开发者_如何学C 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?
My guess is that you pass the wrong selector when you connect the button to the action.
If you have created the button programattically.
- Don't forget to add it to the view.
- The selector should look something like this: `[button addTarget:self action:@selector(pressButton1:) forControlEvents:UIControlEventTouchUpInside];
Note the : in pressButton1:
精彩评论