2012-11-07 80 views
0

不太确定如何解释这一点,但在我的UITableView我有一行代码,当我点击一个单元格时,它将带我到一个新的视图,它根据单元格的名称更新它的标题。然而,如果我有两个单元格,一个名为'One',另一个名为'Two',当我点击'Two'时,它会将我带到标题为'One'的视图,反之亦然。任何想法可能是造成这种情况的原因?对不起,我不能有更多的帮助。TableView加载错误的单元格

-(void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    [self.tableView deselectRowAtIndexPath:indexPath animated:YES]; 
    ACollection *newView = [[ACollection alloc] init]; 
    newView.theTitle = [self.tableView cellForRowAtIndexPath:indexPath].textLabel.text; 
    [self.navigationController pushViewController:newView animated:YES]; 
} 
+0

只显示您的代码段...我想它的逻辑问题 –

+1

提供更多的代码.. w –

+0

请发布'didSelectRowAtIndexPath'代码:) –

回答

1

我想你已经选择了错误的方法,该

刚刚尝试这个代码:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    [self.tableView deselectRowAtIndexPath:indexPath animated:YES]; 

    ACollection *newView = [[ACollection alloc] init]; 
    newView.theTitle = [self.tableView cellForRowAtIndexPath:indexPath].textLabel.text; 
    [self.navigationController pushViewController:newView animated:YES]; 
} 
+0

我有谢谢你!只需注意取消选择,谢谢 –

+0

随时欢迎.... :) –

相关问题