objective-c - 从 indexPath/Swip Gesture 获取单元格名称

标签 objective-c ios uitableview uiswipegesturerecognizer

情况

我希望能够在用户滑动单元格(以显示“删除”按钮)时获取有关 UITableView 中单元格标题的信息。

代码

当用户在 UITableView 中滑动单元格时,将触发此方法:

- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath*)indexPath

问题

我需要能够获取用户“滑动”的单元格的名称,以便我的 iOS (Obj-C) 应用程序可以执行各种操作等。

一切

我知道 indexPath 有一些东西,但我无法从中获取 NSString(这是我需要的)。

我也在考虑使用手势识别器等替代上述方法的变通方法可能能够为我提供有关该单元格的更多信息。

关于当用户“滑动以编辑/删除”时如何获取单元格名称的任何想法?

最佳答案

- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
    NSString *text = cell.textLabel.text;

    // do something with text
}

关于objective-c - 从 indexPath/Swip Gesture 获取单元格名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10840547/

相关文章:

objective-c - 在下一个运行循环 : What's Wrong With GCD? 上执行

ios - UITableViewController 自定义单元格中缺少 UIButton 默认点击淡入淡出动画

objective-c - 在 UIView 中实现 ZBar 二维码阅读器

objective-c - Xcode 创建和使用带有链接错误的静态库

objective-c - 添加SDWebImage框架时出现Xcode Clang错误

android - 如何为移动跨平台网站编写CSS

objective-c - 通过 Casting 调用另一个类中的方法?

ios - 使用 coreData 中的关系快速获取数据

ios - 将数据从 tableview 传回 viewcontroller textfield Objective - C

ios - 具有自动布局的嵌套 UITableView