表格视图单元格选择在转换之前缓慢淡出

时间:2012-05-04 18:27:21

标签: objective-c ios

我在任何应用程序中都看到,在转换到其他视图之前,表格视图单元格选择突出显示会非常平滑地消失。我搜索过这个主题,但我没有找到任何例子。

由于

1 个答案:

答案 0 :(得分:1)

你可以达到你所描述的效果。


-(void)tableView:(UITableView *)tv didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    [tv deselectRowAtIndexPath:indexPath animated:YES];
    double delayInSeconds = .3;
    dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, delayInSeconds * NSEC_PER_SEC);
    dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
        Location *loc = [self.locations objectAtIndex:indexPath.row];
        LocationDetailsController *locationDetails = [[[LocationDetailsController alloc] initWithNibName:nil bundle:nil] autorelease];
        locationDetails.location = loc;
        [self.navigationController pushViewController:locationDetails animated:YES];
    });
}