2011-06-14 132 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: