【发布时间】:2012-04-30 06:38:38
【问题描述】:
在互联网上搜索了很长时间,但没有得到适当的答案。我将 UITableView 置于编辑模式并一次选择多行。它工作得很好,但我想将复选标记的颜色从红色更改为蓝色,就像在 iPhone 电子邮件应用程序中一样。
任何帮助将不胜感激。
编辑版本:
这是我的代码...
在我的 ViewDidLoad 函数中:
- (void)viewDidLoad
{
...
[deviceTableVIew setAllowsSelectionDuringEditing:YES];
[deviceTableVIew setAllowsMultipleSelectionDuringEditing:YES];
[super viewDidLoad];
}
我有两个 UIButtons 设置 tableview 的编辑模式如下:
-(IBAction)control:(id)sender{
btnControl.enabled = false;
btnControl.hidden = true;
btnCancel.enabled = true;
btnCancel.hidden = false;
stateToggleToolbar.hidden = false;
[self.deviceTableVIew setEditing:YES animated:YES];
}
-(IBAction)cancel:(id)sender{
btnCancel.enabled = false;
btnCancel.hidden = true;
btnControl.enabled = true;
btnControl.hidden = false;
stateToggleToolbar.hidden = true;
[self.deviceTableVIew setEditing:NO animated:YES];
}
UITableView 的委托方法是:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
//setting up the cells here
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
...
if ([tableView isEditing] == YES) {
// Do Nothing
}else{
[self.navigationController pushViewController:viewController animated:YES];
}
}
-(void) tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath{
}
- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath{
return 3;
}
【问题讨论】:
-
看看这个希望对你有帮助stackoverflow.com/questions/7641228/…
-
我以前看过参考资料。但是你能告诉我怎么做,因为我是 iPhone 开发的新手。
-
U 制作一个蓝色的自定义图像并使用该 code.cell.accessoryView = checkmark; [复选标记发布];
-
你需要在 cellForRowAtIndex 中写下这个
-
是否可以将左侧文本标签前的复选标记颜色从红色更改为蓝色,就像在 iPhone 电子邮件应用程序中一样。
标签: iphone ios uitableview