iOS UITableViewCell必须长按才能选择项目

 纠结丿灬情殇 发布于 2023-02-11 16:23

所以这让我疯了,每当我在UITableView中点击一个项目它什么都不做,但是当我在大约3-5秒后按住UITableViewCell它决定向前移动并做我想要的..任何想法为什么这可能发生了什么?

这是我的代码

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return 100;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    _cell = [_arrayItems objectAtIndex:indexPath.row];
    _cell = nil;
     static NSString *AutoCompleteRowIdentifier = @"AutoCompleteRowIdentifier";
    _cell = (CustomWidget *)[tableView dequeueReusableCellWithIdentifier:AutoCompleteRowIdentifier];
    if (_cell == nil) {
        _cell = [[CustomWidget alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:AutoCompleteRowIdentifier title:[_arrayItems objectAtIndex:indexPath.row] subTitle:@"Custom subtitle"];
    }

    _cell.textLabel.text = [_arrayItems objectAtIndex:indexPath.row];
    _cell.textLabel.hidden = YES;
    return _cell;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return _arrayItems.count;
}


- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    UITableViewCell *selectedCell = [tableView cellForRowAtIndexPath:indexPath];
    _passedInPageTitle = selectedCell.textLabel.text;
    [self openDetailPage];
}

apb.. 9

我发现我的答案在这里 -我有一个UITapGestureRecognizerUITableView的父视图,这是捕捉龙头.

撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有