gpt4 book ai didi

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

转载 作者:可可西里 更新时间:2023-11-01 05:16:09 25 4
gpt4 key购买 nike

如何在表格单元格上滑动手指并调用函数(在该函数中我将 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com