2012-07-11 36 views
0

嗨朋友我的应用程序崩溃点击单元格bec我对这条线rowToSelect = indexPath;。但我需要这一行我必须通过所有行选择cellbackground图像上的图像当我点击SECTION1 ==排== 0,那么我得到这个错误如何避免iphone中的单元格选择错误

' - [__ NSArrayM行]:无法识别的选择发送到实例0x4c7080' *第一掷调用堆栈:(0x37e378bf 0x379831e5 0x37e3aacb 0x37e39945 0x37d94680 0x319921e9 0x319921af 0x5b47 0x3193f9cb 0x3193eaa9 0x3193e233 0x318e2d29 0x37d9622b 0x37430381 0x3742ff99 0x3743411b 0x37433e57 0x3742bd85 0x37e0bb4b 0 x37e09d87 0x37e0a0e1 0x37d8d4dd 0x37d8d3a5 0x37b64fcd 0x3190d743 0x2927 0x28dc)terminate 调用throwing exceptionProgram received signal:“SIGABRT”。数据 格式化程序暂时不可用,将在“继续”后重新尝试。 (找不到dlopen的功能,所以它是不可能载入共享 库)。

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { 


    rowToSelect=indexPath;//when i remove this line then my application is not crashing but when i keep 

    this line the i click section1 and row0 then application is crash why this happen where i am wong please help me 



     UIViewController <SubstitutableDetailViewController> *detailViewController = nil; 

     if ([indexPath row] == 0 && [indexPath section] == 0) { 
      TodoDetailViewController *newDetailViewController = [[TodoDetailViewController alloc] initWithNibName:@"TodoDetailViewController" bundle:nil]; 
      detailViewController = newDetailViewController; 


     } 

     if ([indexPath row] == 0 && [indexPath section] == 1){ 
      PeopleViewController *newDetailViewController = [[PeopleViewController alloc] initWithNibName:@"PeopleViewController" bundle:nil]; 

      detailViewController = newDetailViewController; 

     } 

     if ([indexPath row] == 1 && [indexPath section] == 1){ 
      DocumentsViewController *newDetailViewController = [[DocumentsViewController alloc] initWithNibName:@"DocumentsViewController" bundle:nil]; 
      detailViewController = newDetailViewController; 
     } 

     if ([indexPath row] == 2 && [indexPath section] == 1){ 
      PlannerViewController *newDetailViewController = [[PlannerViewController alloc] initWithNibName:@"PlannerViewController" bundle:nil]; 
      detailViewController = newDetailViewController; 
     } 



     if ([indexPath row] == 0 && [indexPath section] == 2){ 
      ArchivedPeopleViewController *newDetailViewController = [[ArchivedPeopleViewController alloc] initWithNibName:@"ArchivedPeopleViewController" bundle:nil]; 
      detailViewController = newDetailViewController; 
     } 




     // Update the split view controller's view controllers array. 
     NSArray *viewControllers = [[NSArray alloc] initWithObjects:self.navigationController, detailViewController, nil]; 
     splitViewController.viewControllers = viewControllers; 


     if (popoverController !=nil) 
     { 
      [popoverController dismissPopoverAnimated:YES]; 
     } 
     . 
     if (rootPopoverButtonItem != nil) { 
      [detailViewController showRootPopoverButtonItem:self.rootPopoverButtonItem]; 
     } 
     [detailViewController release]; 

    } 
+1

什么类型是'rowToSelect'场? – 2012-07-11 05:56:00

回答

0

让它作为

rowToSelect=indexPath.row; 
+0

还要确保rowToSelect的类型是NSInteger。 :) – chandu 2012-07-11 06:36:26