【问题标题】:touchesbegan touches only registers one touch even with two fingerstouchesbegan touches 即使用两根手指也只记录一次触摸
【发布时间】:2011-02-24 04:38:56
【问题描述】:

我用两根手指同时触地。我得到 [touches count]=>1 和 [[event allTouches] count] =>2

我不应该给他们两个都买 2 吗?

另外,当我先将一根手指向下放置,然后将另一根手指放在同一个单元格上。第二个手指事件不会导致 touchesBegan 触发?它不应该调用两次 touchesBegan 吗?

我有一个表格单元格,我在其中设置:

multipleTouchEnabled = YES;

这是我的接触开始:

-(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
    NSLog(@"began touch count %d", [touches count]);
    NSLog(@"all touches %d", [[event allTouches] count]);
}

【问题讨论】:

    标签: iphone objective-c


    【解决方案1】:

    使用UITableViewCell 时,触摸似乎发生了一些变化。我的猜测是,这与检测单元格的滑动和触摸的内置处理以及能够处理UITableView 本身的滚动有关。作为一种解决方法,您可以将自己的视图添加到单元格的 contentView 中,以便能够检测到触摸。大致如下:

    MyCustomView *customView = [[MyCustomView alloc] initWithFrame:...];
    customView.multipleTouchEnabled = YES;
    [cell.contentView addSubview:customView];
    [customView release]; 
    

    您在哪里创建单元格,可能在tableView:cellForRowAtIndexPath:

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-01-23
      • 1970-01-01
      • 1970-01-01
      • 2017-09-11
      相关资源
      最近更新 更多