Tag: touch

如何在子视图中检测轻击手势

快速的问题:我如何检测点击手势识别器是否被添加到视图的子视图内? 例如。 如果我点击一个对象,例如已添加为子视图的方块,并添加了轻拍手势识别器,那么如何检测到它已被轻敲?

在iOS应用程序中收听所有触摸事件

是否有可能以某种方式聆听并捕捉应用程序中发生的所有触摸事件? 我正在开发的应用程序将用于展示厅和信息亭,因此,如果在给定的几分钟内没有收到任何触摸,我将回到应用程序的开始部分。 一种屏保function,如果你愿意。 我打算通过在后台运行一个计时器来实现这一点,应该重置和重新启动每次触摸事件发生在应用程序的某个地方。 但是我怎样才能听触摸事件? 任何想法或build议?

如何找出触摸事件结束的视图?

我希望将UIImage拖放到其中一个UIButton上,然后根据我将其拖到哪个button来重新定位UIImage。 我碰到的问题是,UITouch只logging我的触摸开始的视图,我想访问我的触摸结束的视图。 我怎样才能做到这一点? 码: -(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *touch = [touches anyObject]; CGPoint location = [touch locationInView:self.view]; dealerBtnOrigin = [touch locationInView:self.view]; //NSLog(@"%u %u",touch.view.tag, ((UIView *)[dealerBtns objectAtIndex:[table getButtonSeat]]).tag); //CHECK TO SEE WHICH BUTTON WAS TOUCHED if (touch.view == ((UIView *)[dealerBtns objectAtIndex:[table getButtonSeat]])) { ((UIView *)[dealerBtns objectAtIndex:[table getButtonSeat]]).center = location; } } -(void)touchesMoved:(NSSet *)touches […]

在iOS7中检测MKOverlay的触摸(MKOverlayRenderer)

我有一个可能绘制数百个多边形的MKMapView。 假设在iOS7上使用MKPolygon和MKPolygonRenderer。 我需要的是用户触摸其中一个多边形的方式。 例如,它们代表地图上某个人口密度的地区。 在iOS6上,MKOverlay被绘制为MKOverlayViews,因此触摸检测更直接。 现在使用渲染器,我真的不知道这是怎么做的。 我不确定这会帮助甚至是相关的,但作为参考,我会张贴一些代码: 这使用mapData将所有MKOverlay添加到MKMapView。 -(void)drawPolygons{ self.polygonsInfo = [NSMutableDictionary dictionary]; NSArray *polygons = [self.mapData valueForKeyPath:@"polygons"]; for(NSDictionary *polygonInfo in polygons){ NSArray *polygonPoints = [polygonInfo objectForKey:@"boundary"]; int numberOfPoints = [polygonPoints count]; CLLocationCoordinate2D *coordinates = malloc(numberOfPoints * sizeof(CLLocationCoordinate2D)); for (int i = 0; i < numberOfPoints; i++){ NSDictionary *pointInfo = [polygonPoints objectAtIndex:i]; CLLocationCoordinate2D point; point.latitude […]

如何从挖掘位置获取CGPoint?

我正在为iPaddevise一个graphics计算器应用程序,我想添加一个function,用户可以在graphics视图中点击一个区域,使文本框popup,显示它们所触摸的点的坐标。 我怎样才能从这个CGPoint?