小编ste*_*rro的帖子

UITableViewCell GestureReognizer的性能问题

我在UITableViewCells中添加了单击和双击手势识别器.但是在滚动表格几次之后,在我的滑动手势结束以滚动表格和滚动动画的开始之间会出现越来越长的暂停.

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"tableViewCell";

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

    UITapGestureRecognizer* singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(singleTap:)];
    singleTap.numberOfTapsRequired = 1;
    singleTap.numberOfTouchesRequired = 1;
    [cell addGestureRecognizer:singleTap];

    UITapGestureRecognizer* doubleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(doubleTap:)];
    doubleTap.numberOfTapsRequired = 2;
    doubleTap.numberOfTouchesRequired = 1;
    [singleTap requireGestureRecognizerToFail:doubleTap];
    [cell addGestureRecognizer:doubleTap];

    if (tableView == self.searchDisplayController.searchResultsTableView) {
        // search results
    }
    else {
        // normal table
    }

    return cell;
} …
Run Code Online (Sandbox Code Playgroud)

uitableview ios uitapgesturerecognizer

1
推荐指数
1
解决办法
2104
查看次数

标签 统计

ios ×1

uitableview ×1

uitapgesturerecognizer ×1