I believe you use dequeueReusableCellWithReuseIdentifier in method tableView:cellForRowAtIndexPath.
If you do use it, then the reason behind is, when you scroll down to section 1, the tableview will automatically check the cell pool and get an available cell with the same identifier and assign to each row in section 1. If no cell is found then you will have some thing like:
if (cell == nil)
{
//Create new cell with an identifier
}
Since your 1st row and section 0 (the text field) is not visible anymore and will be returned to the cell pool, the table view will take it and use for a random row in section 1 (for your case is 3, 6, 9, etc.). That's why you can't select those rows in section 1,
So tweak ur code and try if it helps:
@property (nonatomic, strong) UITapGestureRecognizer *tapRecognizer;
- (void) viewDidLoad{
//Do stuffs as usual
self.tapRecognizer = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(didTapAnywhere:)];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
..
if(indexPath.section == 0)
{
//cell don't have the tap recognizer yet
if (cell.contentView.gestureRecognizers == nil || ![cell.contentView.gestureRecognizers containsObject:self.tapRecognizer])
{
if (self.tapRecognizer.view != nil)
[self.tabRecognizer.view removeGestureRecognizer:self.tabRecognizer];
[cell.contentView addGestureRecognizer:tapRecognizer];
}
}
else if (cell.contentView.gestureRecognizers != nil && [cell.contentView.gestureRecognizers containsObject:self.tapRecognizer])
[cell.contentView removeGestureRecognizer:self.tabRecognizer];
..
}
That's the logic, you can based on that to solve your problem :-D