簡體   English   中英

如何在表格單元格上滑動並使其調用 function?

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM