IOS7表格视图单元格触摸延迟与单元格属性UITableViewCellSelectionStyleNone

时间:2014-06-01 05:22:14

标签: ios objective-c ios7 uitableview custom-cell

我想制作一个像这样的自定义表格视图。

  • 如果cell.selectionStyle = UITableViewCellSelectionStyleDefault,触摸时没有延迟,但我的标题标签的背景颜色消失了。

  • 如果cell.selectionStyle = UITableViewCellSelectionStyleNone,标题标签的背景颜色很好,但是提示模式VC有触摸延迟。提前致谢!

1 个答案:

答案 0 :(得分:0)

您可以在UITableViewDelegate方法

下实施类似的内容
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

    UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];

    switch (cell.selectionStyle) {

        case UITableViewCellSelectionStyleNone:

            // your are making an delay with NSTimer
            [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(trigger:) userInfo:cell repeats:NO];
            break;

        case UITableViewCellSelectionStyleDefault:

            // changing your labels color
            [cell.textLabel setBackgroundColor:[UIColor whiteColor]];
            break;

        default:
            break;
    }

}

- (void)trigger:(id)timer {

    UITableViewCell *cell = (UITableViewCell *)[timer userInfo];

    // _yourModelController is your destination controller
    [self presentViewController:_yourModelController animated:YES completion:NULL];
}

但我个人并不建议根据selectionStyle属性做出决策。

相关问题