2

私のビューには 1 つの UITableView があります。私の UITableView の名前は tblTask​​ です。
ビューの x 座標と y 座標を取得するために touchesBegan メソッドを使用しています。

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    UITouch *touch = [touches anyObject];
    CGPoint location = [touch locationInView:self.view];

    NSLog(@"point........ %f .. %f",location.x,location.y);



}

しかし、tbltask からタッチ イベントを開始すると。tbltask がメイン ビューのサブビューであっても、location.x と location.y は返されません。

テーブルのスクロールビューも無効にしようとしましたが、何も起こりません。
これを設定すると。

tbltask.userInteractionEnabled=NO;

その後、座標が表示されますが、tbltask インタラクションが有効になっている場合でもビューの座標が必要です。

4

1 に答える 1

4
-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
     UITouch *touch ;
     touch = [[event allTouches] anyObject];
     if ([touch view] == self.view){
         CGPoint location = [touch locationInView:touch.view];
         NSLog(@"point........ %f .. %f",location.x,location.y);
      }
}
于 2012-04-18T17:39:59.907 に答える