我非常想暂时突出显示UITableViewCell,以引起人们注意包含数据已更改的事实。有一个UITableViewCell方法:-setHighlighted:(布尔)动画:(布尔),但我不能让它做任何事情?如何突出显示UITableViewCell
这里是视图控制器的相关部分:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell;
switch (indexPath.section) {
case 0: {
if (indexPath.row == 0) {
cell = [[UITableViewCell alloc ] initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:@"currentLoc"];
cell.accessoryType = UITableViewCellAccessoryNone;
cell.textLabel.text = @"This is the special cell";
}
[cell setHighlighted:YES animated:YES];
[cell setHighlighted:NO animated:YES];
//[cell setNeedsDisplay];
} else {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:@"setLocAutomatically"];
cell.accessoryType = UITableViewCellAccessoryNone;
cell.textLabel.text = @"Foo";
}
} break;
case 1: {
cell = [[UITableViewCell alloc ] initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:@"selectCity"];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
if (indexPath.row == 0) {
cell.textLabel.text = @"Select a Bar";
} else {
cell.textLabel.text = @"Select a Baz";
}
} break;
}
[cell autorelease];
return cell;
}
参见[电池setHighlight ...]以上为我的尝试。
很让我沮丧的是,单元格没有突出显示,我还没有想出任何方法使其工作。
谢谢
卡尔Ç-M
这个工作对我来说,应该是接受的答案是,imo。 – 2011-01-16 05:22:14
也适用于我 – z22 2014-07-16 09:08:44