不太确定如何解释这一点,但在我的 UITableView
上,我有一行代码,当我单击一个单元格时,它会将我带到一个新 View ,该 View 根据名称更新其标题细胞。但是,如果我有两个单元格,一个名为“一”,一个名为“二”,当我单击“二”时,它会将我带到标题为“一”的 View ,反之亦然。知道可能是什么原因造成的吗?抱歉,我无法提供更多帮助。
-(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];
}
最佳答案
我认为您为此选择了错误的方法
试试这个代码:
- (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];
}
关于iphone - TableView 加载错误的单元格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13269439/