如何编程UITableViewCell短暂闪烁?

时间:2012-07-13 20:26:08

标签: uitableview

我有一个UITableView,我刚刚插入了一个新行,检索了该行的NSIndexPath,并滚动到它。如何使此行的单元格短暂闪烁?

int indexOfRow = //retrieve row index
NSIndexPath *indexPath =  [NSIndexPath indexPathForRow:indexOfRow inSection:0];
[self.tableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionTop animated:YES];
//cause cell to blink

接下来是什么?

2 个答案:

答案 0 :(得分:0)

你走了:

UITableViewCell *tableCell = [[self tableView] cellForRowAtIndexPath:indexPath];
[tableCell setHighlighted:YES animated:NO];
[tableCell setHighlighted:NO animated:YES];

答案 1 :(得分:0)

试试这个:

- (void) someMethod {
    //your other code
    //...

    UITableViewCell *tableCell = [[self tableView] cellForRowAtIndexPath:indexPath];
    [tableCell setHighlighted:YES animated:NO];
    [self performSelector:@selector(completeCellBlink:) withObject:tableCell afterDelay:0.2];

}

- (void) completeCellBlink: (UITableViewCell*) cell {
    [tableCell setHighlighted:NO animated:YES];
}

延迟以秒为单位,您当然可以更改该值以调整视觉印象。