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