[英]How can i swipe on a table cell and make it call a function?
我如何在表格單元格上滑動手指並調用 function (在其中我將視圖 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");
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.