2011-06-14 129 views
0

我有一个表格视图,我把一个工具栏按钮,所以当点击按钮打开地图视图。 当我按一下按钮我的应用程序崩溃,所以我想这:导致崩溃的按钮

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

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

当我点击相应的单元格就打开新的观点和我的MapView的工作就像一个魅力 但是,当我在按钮放在相同的action方法我的应用程序崩溃。

任何想法?

+1

你能告诉你如何实现的操作方法? – 2011-06-14 12:37:17

+0

你可以显示崩溃日志吗? – jv42 2011-06-14 12:41:20

+0

- (void)pressButton1:(id)sender MapViewController * mvc = [[MapViewController alloc] initWithNibName:@“MapViewController”bundle:nil]; [self.navigationController pushViewController:mvc animated:YES];} //崩溃日志: buttonPressed:]:无法识别的选择器发送到实例0x5853470 2011-06-14 15:11:14.374 TattooShops [16644:207] * **因未捕获异常'NSInvalidArgumentException'而终止应用,原因:' - [MonteraController buttonPressed:]:无法识别的选择器发送到实例0x5853470' 终止在调用'NSException' – ALEX 2011-06-14 13:22:05

回答

1

我的猜测是,当您将按钮连接到动作时,您通过了错误的选择器。

如果您已经按程式创建了按钮。

  1. 不要忘记将它添加到视图中。这个选择器应该看起来像这样:`[button addTarget:self action:@selector(pressButton1 :) forControlEvents:UIControlEventTouchUpInside];

注意在pressButton1: