我想在UITableViewCell里增加一个switch,并且还保留原来的IMAGE,LABEL,但我又不想完全用代码实现,也不想完全用INTERFACE BUILDER画出来。
1、新建一个XIB文件,拖SWITCH放到右边
2、新建类,继承UITableViewCell,叫StatusCell
3、指定XIB的类为StatusCell
4、
{
static NSString *CellIdentifier = @"StatusCell";
// 状态的CELL
StatusCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
NSBundle *myBundle = [NSBundle mainBundle];
cell =[[myBundle loadNibNamed:@"StatusCell" owner:self options:nil] lastObject]; }
// Configure the cell...
//cell.textLabel.text = [self.dataArray objectAtIndex:indexPath.row];
cell.textLabel.text=[self.dataArray objectAtIndex:indexPath.row];
cell.textLabel.backgroundColor=[UIColor clearColor];
cell.imageView.image=[UIImage imageNamed:@"lockoverlay"];
return cell;
}