2013-07-23 44 views
0

为什么在执行willSelectRowAtIndexPath之后以及在didSelectRowAtIndexPath之前生成EXC_BAD_ADRESS? 没有willSelectRowAtIndexPath实现它完美的作品。执行willSelectRowAtIndexPath之后生成EXC_BAD_ADRESS

这里是我的代码:

- (void)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath 
    { 
     KMWTableViewCell *cell = (KMWTableViewCell *) [tableView cellForRowAtIndexPath:indexPath]; 
     if(cell){ 
      cell.visibleView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"cellBackPressed.png"]]; 
     } 
    } 

    -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
    { 
     KMWTableViewCell *cell = (KMWTableViewCell *) [tableView cellForRowAtIndexPath:indexPath]; 
     if(cell){ 
      [self setCurrentAccountId:[[[KMWAppDelegate accounts] objectAtIndex:indexPath.section] objectForKey:@"accountId"]]; 
      [self performSegueWithIdentifier:@"services" sender:self]; 
     } 
    } 
+0

它在哪条线上崩溃? –

+0

这些方法之间的某处。不在我的代码中。 –

+1

'willSelectRowAtIndexPath:'应该返回'NSIndexPath'。 – Desdenova

回答

5

方法签名是错误的。它的返回值应该是NSIndexPath

- (NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    KMWTableViewCell *cell = (KMWTableViewCell *) [tableView cellForRowAtIndexPath:indexPath]; 
    if(cell){ 
     cell.visibleView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"cellBackPressed.png"]]; 
    } 

    return indexPath; 
} 

在您实现您最后需要返回给定indexPath

相关问题