ios - TableView :didSelectRowAtIndexPath/popViewControllerAnimated do not work

标签 ios objective-c uitableview

当我使用时

tableView:didSelectRowAtIndexPath / popViewControllerAnimated

它不起作用。我通过另一个 View 插入 View Controller ,但是当我选择一行时,它会以灰色突出显示,而不是立即弹出到原始 View Controller 。但是当我点击另一行时,它会选择我点击的第一行,然后返回到原始 View Controller 。

这是代码:

- (void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];

    cell.accessoryType = UITableViewCellAccessoryCheckmark;

    NSArray *allTypes = [[ItemStore sharedStore] allTypes];
    NSManagedObject *raum = allTypes[indexPath.row];
    self.an.leben = raum;

    [self.navigationController popViewControllerAnimated:YES];
}

有什么想法吗?

最佳答案

didDeselectRowAtIndexPath 替换为 didSelectRowAtIndexPath

您编写的委托(delegate)方法是didDeselectRowAtIndexPath,而不是didSelectRowAtIndexPath。 根据苹果的说法,tableView:didDeselectRowAtIndexPath: 告诉代理指定的行现在已取消选择

tableView:didSelectRowAtIndexPath: 告诉代理指定的行现在已选择

因此,发生的情况是,当您单击一行时,它会被选中并变成灰色,然后当您单击同一行或任何其他行时,前一行会被取消选择,因为一次只选择一行,并且因此调用此方法来打开带有上一个点击行的下一个 View Controller 。

关于ios - TableView :didSelectRowAtIndexPath/popViewControllerAnimated do not work,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23592178/

相关文章:

ios - 我们可以将 iOS 原生 map 用于混合应用程序吗?

ios - 如何在 xcode 5 中运行 ios 6 模拟器?

ios - 分段控件更改时更新 rightBarButtonItems

ios - Clang 在 objective-c 中因退出代码 1 错误而失败

ios - 重新编译现有的 objective c 库以支持 arm8

ios - ios中的动态单元格高度在swift中以编程方式使用约束

swift - 如何使用 UITableViewAutomaticDimension?

objective-c - Cocos2d 中的 "Attempting to use the forward class ' 游戏 ' as superclass of ' MathGame '"

objective-c - NSString substringWithRange 返回错误的子字符串

ios - UITableview 中的自定义单元格合并