Kev*_*tre 3 iphone cocoa-touch uitableview
我有一个基本的UITableView,我想在没有选择样式的情况下启用Mail.app样式复选标记.我有以下代码段:
#define UITableViewCellEditingStyleMultiSelect (3)
- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView
editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath
{
return UITableViewCellEditingStyleMultiSelect;
}
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nil];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
return cell;
}
Run Code Online (Sandbox Code Playgroud)
但是,这将永远不会在选择上显示复选标记(尽管显示空心圆圈).关于如何修复它的任何想法?我知道它使用了未记录的功能,但我真的想添加对复选标记的支持.我的实际例子使用非常自定义UITableViewCell
,我无法启用选择样式!
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nil];
if (self.tableView.isEditing) {
cell.selectionStyle = UITableViewCellSelectionStyleBlue;
} else {
cell.selectionStyle = UITableViewCellSelectionStyleNone;
}
return cell;
}
-(UITableViewCellEditingStyle) tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath {
return UITableViewCellEditingStyleMultiSelect;
}
-(IBAction) switchEditing {
[self.tableView setEditing:![self.tableView isEditing]];
[self.tableView reloadData]; // force reload to reset selection style
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
6411 次 |
最近记录: |