簡體   English   中英

iOS UITableViewCell必須長按才能選擇項目

[英]iOS UITableViewCell Have To Hold A Long Press To Select Item

所以這讓我瘋了,每當我點擊我的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];
}

我在這里找到了答案 - 我在UITableView的父視圖上有一個UITapGestureRecognizer ,它捕獲了水龍頭。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

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