iphone - 如何在表格单元格上滑动并使其调用函数?

标签 iphone ios cocoa-touch

如何在表格单元格上滑动手指并调用函数(在该函数中我将 View Controller 推送到我的导航 Controller )?

最佳答案

只需将 UISwipeGestureRecognizer 添加到单元格即可。

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
    cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];

    UISwipeGestureRecognizer *g = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(cellWasSwiped:)];
    [cell addGestureRecognizer:g];
    [g release];
}

然后实现处理滑动的方法:

- (void)cellWasSwiped:(UIGestureRecognizer *)g {
    NSLog(@"Swiped");
}

关于iphone - 如何在表格单元格上滑动并使其调用函数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6621698/

相关文章:

ios - 谷歌日历数据的 NSDateFormatter dateFormat

objective-c - 通过segue传递数据

iphone - iPhone 核心数据新功能

ios - 使用 ARC 加载许多 .jpg 文件时收到内存警告和崩溃

iphone - map View 注释调整

iphone - 如何用 2 根手指在 iOS 4 中滚动 iframe?

ios - 将过滤器应用于 UIScrollView GPUImage 中的当前图像索引

iphone - 如何计算iPhone ScrollView 的动态大小?

iphone - 在 iOS 应用程序中调用 "secret"URL 有多安全?

objective-c - iOS 哪个是标签栏图标的默认 UIColor?