相关疑难解决方法(0)

UITableViewCell accessoryType设置,但accessoryView是零.如何设置accessoryView backgroundColor?

以下是我的单元格设置方式:

- (UITableViewCell *)tableView:(UITableView *)tableViewIn cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *CellIdentifier = @"subcategory";
    UITableViewCell *cell = [tableViewIn dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
    }
    cell.textLabel.text = [[subcategories objectAtIndex:indexPath.row] title];
    cell.textLabel.font = [UIFont boldSystemFontOfSize:16];
    cell.textLabel.font = [UIFont boldSystemFontOfSize:16];
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    cell.selectionStyle = UITableViewCellSelectionStyleGray;

    cell.contentView.backgroundColor = [UIColor clearColor];

    cell.textLabel.textColor = [UIColor whiteColor];
    cell.textLabel.highlightedTextColor = [UIColor whiteColor];

    return cell;
}    
Run Code Online (Sandbox Code Playgroud)

正如人们所看到的,我设置的背景contentView,而且工作得很好-但是当我尝试做同样的事情backgroundView或者accessoryView,什么都不会发生,因为backgroundViewaccessoryView这两个似乎是零.

当一个人设置accessoryType而不是accessoryView …

iphone cocoa-touch objective-c ios

7
推荐指数
1
解决办法
1万
查看次数

标签 统计

cocoa-touch ×1

ios ×1

iphone ×1

objective-c ×1