2014-10-13 2 views
-1

У меня проблема при выборе строки в таблицеView, проблема в том, что когда я выбираю строку в первый раз, она выделяется серым цветом, но ничего не происходит, и мне нужно снова выбрать строку для выполнения "didSelectRowAtIndexPath" и берет меня к другой ViewControllerСтрока выбора на tableView iOS

// 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]; 
} 
+2

replace - (void) tableView: (UITableView *) tableView didDeselectRowAtIndexPath: (NSIndexPath *) indexPath с - (void) tableView: (UITableView *) tableView didSelectRowAtIndexPath: (NSIndexPath *) indexPath – hariszaman

ответ

4

я нашел проблемы вы сохранили didDeselectRowAtIndexPath метод в месте didSelectRowAtIndexPath:

-(void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath; 
5

Вы случайно реализованы DESELECT rowAtIndexPAth, не ВЫБРАТЬ rowAtIndexPath.

1

обновить свой код следующим кодом:

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(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]; 
} 
0

Вы реализовали didDeselectRowAtIndexPath, это должно быть didSelectRowAtIndexPath :

-(void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath; 
Смежные вопросы