iphone - TableView 加载错误的单元格

标签 iphone ios uitableview

不太确定如何解释这一点,但在我的 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/

相关文章:

ios - tableView didSelectRowAtIndexPath 无法正常工作

iphone - 表编辑完成后,UISwitch 在 UITableViewCell 中仍然略微可见

iphone - iPhone 上的大事件指示器

ios - 如何在 Xcode 12.4 上运行 iOS 模拟器 10.3.1?

objective-c - 等待 NSURLConnection

ios - 访问 UIAlertControllers 文本字段

ios - UITableViewCell 背景 View 图像未下载并显示正确的图像

iOS swift : UITableView KeyPad overlay

iphone - UISegmentControl配置

ios - 在 iOS 设备上运行 swift 应用程序时出现 THREAD 1 : EXC_BREAKPOINT (code = EXC_ARM_BREAKPOINT. ..) 错误