2011-09-09 28 views
0

こんにちは私はグループ化されたテーブルビューを使用していて、blueselectionスタイルのTableviewのセルを選択しています。テーブルビューのセル選択の問題

しかし、セルを選択して次のビューに戻って再び前のビューに戻ると、セルはまだ選択されています。別のセルを選択した場合、2セルが選択されて表示されます。

は、画像と下の私のコードでを参照してください。

enter image description here

// Customize the appearance of table view cells. 
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 

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

    if (cell == nil) { 

     if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { 
      [[NSBundle mainBundle] loadNibNamed:@"iPadJobViewCell" owner:self options:nil]; 
      cell = self.JobViewcell; 
     } 
     else { 
     [[NSBundle mainBundle] loadNibNamed:@"JobViewTableCell" owner:self options:nil]; 
     cell = self.JobViewcell; 

     } 
    } 


    [cell setJobID:[NSString stringWithFormat: @"%@",[(Jobs *)[tableArray objectAtIndex:indexPath.row]JobId]]]; 
    [cell setJobTitle:[NSString stringWithFormat:@"%@",[(Jobs *)[tableArray objectAtIndex:indexPath.row]Title]]]; 

    NSString *newDate =[NSString stringWithFormat:@"%@",[(Jobs *)[tableArray objectAtIndex:indexPath.row]Date]]; 

    NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init]; 
    [dateFormat setDateFormat:@"MM/dd/yyyy h:mm:ss a"]; 
    NSDate *myDate = [dateFormat dateFromString:newDate]; 
    [dateFormat setDateFormat:@"MM/dd/yyyy"]; 

    NSString *str = [dateFormat stringFromDate:myDate]; 

    NSLog(@"%@",str); 



    [cell setJobDate:[NSString stringWithFormat:@"%@",str]]; 
    [cell setLocation:[NSString stringWithFormat:@"%@",[(Jobs *)[tableArray objectAtIndex:indexPath.row]Location]]]; 
    [dateFormat release]; 
    return cell; 
} 

deselectRowAtIndexPathを追加し、あなたのtableViewのdidSelectRowAtIndexPath方法で

答えて

6

を助けてください:

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
    [tableView deselectRowAtIndexPath:[tableView indexPathForSelectedRow] animated:NO]; 
    . . . 
} 
+0

おかげで...それうまくいきます – iProgrammer

関連する問題