2014-02-06 4 views
0

2 개의 테이블 뷰가 있습니다. 첫 번째 테이블 뷰의 선택된 행에 따라 두 번째 뷰의 셀 스타일을 사용자 정의하고 싶습니다. 액세서리를 커스터마이징 할 때 작동하지만 스타일에는 적합하지 않습니다. 난 당신이 새로운 세포를 생성하지 않고 셀의 스타일을 변경할 수 없습니다 사전UITableView 셀 스타일을 변경하십시오.

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ 
    static NSString *TableIdentifier = @"Cell"; 

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:TableIdentifier]; 

    if (cell == nil) { 
     cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:TableIdentifier]; 
    } 

    cell.detailTextLabel.textColor = [UIColor lightGrayColor]; 
    cell.textLabel.text = [array objectAtIndex:indexPath.row]; 

    if ([selectedRow isEqualToString:@"Cars"]) { 
     [cell setAccessoryType: UITableViewCellAccessoryDetailButton]; 

    } 
    if ([selectedRow isEqualToString:@"Houses"]) { 
     NSArray *temp = [[dic objectForKey:selectedRow]valueForKey:@"Job"]; 

     cell.selectionStyle = UITableViewCellStyleSubtitle; 
     cell.detailTextLabel.adjustsFontSizeToFitWidth = YES; 
     cell.detailTextLabel.text = [temp objectAtIndex:indexPath.row];    
    } 
    if ([selectedRow isEqualToString:@"Libraries"]) { 
     cell.selectionStyle = UITableViewCellStyleValue1; 
    } 

    return cell; 
} 

답변

2

에 다음 코드를

감사를 사용하는 등 아이폰 OS 7.1와 엑스 코드 5.1 을 사용하고 있습니다.

라인 :

cell.selectionStyle = UITableViewCellStyleValue1; 

가 이해되지 않는다. 셀 스타일에 대한 enum 값을 전달하여 셀의 선택 스타일을 변경하려고합니다. 그것은 두 가지 다른 개념입니다.

셀 스타일 (선택 스타일 아님)을 업데이트하려면 UITableView initWithStyle:reuseIdentifier:을 다시 호출하여 원하는 스타일로 전달해야합니다.