user1940321
user1940321

Reputation:

iOS UITableViewCell Have To Hold A Long Press To Select Item

So this is driving me nuts, whenever I tap an item in my UITableView it does nothing, but when i press and hold the UITableViewCell after about 3-5 seconds it decides to move forward and do what I want.. any thoughts why this might be happening?

Here's my code

- (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];
}

Upvotes: 10

Views: 4925

Answers (1)

apb
apb

Reputation: 3370

I found my answer here - I had a UITapGestureRecognizer on the UITableView's parent view, which was capturing the tap.

Upvotes: 9

Related Questions