tableView iOS上的选择行

saz*_*azz -1 objective-c selection uitableview ios

我在tableView中选择一行时遇到问题,问题是当我第一次选择一行时,它会以灰色突出显示但没有任何反应,我必须再次选择一行来执行"didSelectRowAtIndexPath"并执行我到另一个ViewController

// Number of rows in the tableView
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section     {
return 6;
}

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

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

// Populating each cell at a time.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    static NSString *CellIdentifier = @"Cell";
    ClientCustomCell *cell = (ClientCustomCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];

    if (cell == nil) {
        [[NSBundle mainBundle] loadNibNamed:@"ClientCustomCell" owner:self options:nil];
        cell = self.clientCustomCell;
        self.clientCustomCell = nil;

        cell.name = [nameArray objectAtIndex:indexPath.row];
        cell.number = [numberArray objectAtIndex:indexPath.row];
        cell.postal = [postalArray objectAtIndex:indexPath.row];
        cell.locality = [localityArray objectAtIndex:indexPath.row];
    }
    [cell setSelectionStyle:(UITableViewCellSelectionStyleBlue)];
    return cell;
}

-(void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    NSLog(@"row selecter %d", (int)indexPath.row);
    InfoViewController *info = [[InfoViewController alloc] init];
    [self.navigationController pushViewController:info animated:YES];
}
Run Code Online (Sandbox Code Playgroud)

pba*_*sdf 5

您不小心实现了DESELECT rowAtIndexPAth,而不是SELECT rowAtIndexPath.