【问题标题】:UITouch events calls / works only once. not works second time,UITouch 事件调用/只工作一次。第二次不行,
【发布时间】:2013-09-03 05:29:15
【问题描述】:

在我的应用程序中我在我的视图中添加了一个谷歌地图。

I want to know the touch point on the mapView / myView,我在哪里录的

所以我实现的逻辑如下。

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    CGPoint touchPoint  = [[touches anyObject] locationInView:mapView_];
     CGPoint touchPoint2  = [[touches anyObject] locationInView:self.view];



    NSLog(@"========== %@", NSStringFromCGPoint(touchPoint));
    NSLog(@"========== %@", NSStringFromCGPoint(touchPoint2));

   //UITouch *touch = [[event allTouches] anyObject];
     //CGPoint touchPoint = [touch locationInView:touch.view];

}

但它仅适用于第一次触摸,从下一次触摸事件开始,此方法不会调用。

我不明白问题是什么

【问题讨论】:

  • 我只尝试过这段代码,令人惊讶的是,每次我在任何时候触摸内部视图时它都会调用并完美记录值
  • 是的,它适用于所有其他视图非常好.. 但是,在我当前的视图中没有谷歌地图视图

标签: iphone objective-c uitouch gmsmapview


【解决方案1】:

你无法在地图上获取触摸位置,当我们触摸它时,它会变成缩放,触摸事件在 UIView 上

【讨论】:

  • 谁告诉你我们不能在地图上进行触摸事件?只有当我们轻按它时,地图才会缩放。
【解决方案2】:

在这个帮助下,每次我用精确的接触点触摸 mapview 时,我都会得到一个日志

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    CGPoint touchPoint  = [[touches anyObject] locationInView:self.viewMap];
    NSLog(@"==========1 %@", NSStringFromCGPoint(touchPoint));
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-12-03
    • 1970-01-01
    • 2011-11-21
    • 1970-01-01
    相关资源
    最近更新 更多