【发布时间】:2017-01-22 16:29:49
【问题描述】:
我有 11 行或更多行数。只需要在第一个单元格中创建一个 UISwitch。当我点击任何一行时,UIswitch 会被复制。
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:EN_MoreTableViewCell];
if (cell == nil) {
cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:EN_MoreTableViewCell];
cell.backgroundColor = [UIColor clearColor];
}
cell.textLabel.text = languageObject.name;
[cell.textLabel setFont:font];
if (indexPath.row == 0 && [languageObject.name isEqual: @"All Languages"]) {
if (!mySwitch) {
mySwitch = [[UISwitch alloc] initWithFrame:CGRectMake(_languageListTableView.frame.size.width - 60, 0, 40, 40)];
[cell.contentView addSubview:mySwitch];
}
cell.accessoryType = UITableViewCellAccessoryNone;
}
else { //other cell code//
}
请帮忙。
【问题讨论】:
-
请格式化您的代码。
-
最方便的方法是在 Interface Builder 中创建两个单独的表格视图单元格。
标签: ios objective-c uitableview uiswitch