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;
}