Tag: uigesturerecognizer

superview的手势应该取消iOS 7中的子视图的手势?

几年以来,我一直在假设,如果一个超级观点和它的子视图都有手势识别器,子视图将首先接收触摸并取消超级观点的手势。 直到iOS 7这个假设从来没有让我失望,让我添加手势子视图相信超级观点的手势不会干涉。 但是在iOS 7中,超级视图会先随机接收触摸并取消子视图的手势。 这种情况很less发生,这使问题很难被发现。 我第一次遇到这个问题,作为无法使用UITapGestureRecognizer窃听的UITapGestureRecognizer …再次,很less。 通常button将工作,直到他们没有。 让你质疑你的理智。 所以我推出了我自己的TapGestureRecognizer ,发现TapGestureRecognizer水龙头有时会取消他们的子视图的水龙头。 这在以前的iOS版本中从来没有这样做过,但是我想知道这种行为是否从未被承诺过。 我以为子视图的手势应该取消它的超级查看手势(除非委托人另有规定)。 这是错的还是这是一个错误? 请注意:我不是问如何处理这种情况。 我问,如果有人知道我的假设是不正确的。 我已经重新排列视图,dynamic地添加/删除手势,并创buildgestureRecognizer:shouldReceiveTouch:相当复杂的实现gestureRecognizer:shouldReceiveTouch:纠正这种情况。 这并不好玩,但我可以解决这个问题。

将垂直滚动手势传递给下面的UITableView

(为清晰起见编辑) 我有一个UITableView。 最重要的是附有平移手势的UIView。 这个Pan向左和向右滑动来改变底层的表格。 我使用平移手势的动作方法来移动表格。 这工作正常。 但是,UIView及其平移手势会干扰向上/向下滚动UITableView。 我怎样才能发送上/下滚动到桌子上,并保持在视图的区域左右? ————————————— | | | ———————- | | | | | | | | | | | | | | UITableView | | | | | UIView | | | | + | | | | PanGesture | | | | | | | | | | | […]

UISystemGateGestureRecognizer和延迟接近屏幕底部的水龙头

iOS应用程序顶级UIView上安装的标准UISystemGestureGateGestureRecognizers是什么? 我的应用程序包含两个视图 – 一个填充屏幕的上半部分,另一个是自定义键盘,并填充下半部分。 我发现空格键上的水龙头并不总是工作,经过一些调查发现,最低20像素左右的水龙头事件的时间与其余部分不同。 对于大部分的观点来说,touchesBegan / Ended之间的时间间隔大约是100ms,而空格键是1-2ms。 (我的应用程序是一个模拟器,这是太快,它检测到按键)。 经过一些挖掘,我发现应用程序的主要UIView (即:我的主视图的UISystemGestureGateGestureRecognizer视图)有2个UISystemGestureGateGestureRecognizer的安装。 通过在ViewDidAppear删除它们, ViewDidAppear的底部不再受到影响。 (推测这些取消触摸按下事件到我的键盘,因此更快的时间)。 这些系统识别器至less在iOS 5至iOS 7以及iPad和iPhone上都有。 我以为他们可能是从顶部/底部刷卡有关,但这个function仍然适用于他们删除。 所以我有一个解决办法,但我想更多地了解这里发生了什么 – 特别是我可能会通过删除这些。

添加一个UITapGestureRecognizer到UIWebView

在iOS中,是否可以在UIWebView上放置一个轻敲识别器,以便当有人单击Web视图时,会执行一个操作? 当我点击我的webView时,下面的代码似乎不fireTapTap。 谢谢。 UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTap)]; tap.numberOfTapsRequired = 1; [webView addGestureRecognizer:tap]; [tap release]; -(void) handleTap { NSLog(@"tap"); }

如何精确地在图像模式上绘制线条

我有一个UIImageView。 里面,我画线用户触摸事件。 问题是UIImageview任何位置都可以绘制UIImageview ,但是我只喜欢用图像模式绘制线条。 例如,看这个图像。 我只需要在图像模式上画线。 这是我的代码: -(void)touchesMoved:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event { UITouch *touch = [[event allTouches] anyObject]; touchPoint = [touch locationInView:self.imgColor]; UIBezierPath *path = [UIBezierPath bezierPath]; [path moveToPoint:CGPointMake(touchPoint.x,touchPoint.y)]; [path addLineToPoint:CGPointMake(startingPoint.x,startingPoint.y)]; startingPoint=touchPoint; CAShapeLayer *shapeLayer = [CAShapeLayer layer]; shapeLayer.path = [path CGPath]; shapeLayer.strokeColor = [[UIColor blueColor] CGColor]; shapeLayer.lineWidth = 3.0; shapeLayer.fillColor = [[UIColor redColor] CGColor]; […]

ios UICollectionView检测滚动方向

我有一个collectionView。 我想检测滚动方向。 我有一个两个不同的animation风格,向下滚动和向上滚动。 所以我必须学习滚动方向。 CGPoint scrollVelocity = [self.collectionView.panGestureRecognizer velocityInView:self.collectionView.superview]; if (scrollVelocity.y > 0.0f) NSLog(@"scroll up"); else if(scrollVelocity.y < 0.0f) NSLog(@"scroll down"); 这只是在手指触摸工作。 不为我工作

UITableViewCell上的UIPanGestureRecognizer覆盖UITableView的滚动视图手势识别器

我已经分类了UITableViewCell并且在这个类中我应用了一个Pan手势识别器: UIPanGestureRecognizer *panning = [[UIPanGestureRecognizer alloc]initWithTarget:self action:@selector(handlePanning:)]; panning.minimumNumberOfTouches = 1; panning.maximumNumberOfTouches = 1; [self.contentView addGestureRecognizer:panning]; [panning release]; 然后,我实现了这个委托协议,它应该允许在表格视图中同时使用手势: – (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer { return YES; } 然后在handlePanning方法中放置一个日志,以查看它何时被检测到: – (void)handlePanning:(UIPanGestureRecognizer *)sender { NSLog(@"PAN"); } 我的问题是,我无法垂直滚动tableview中的单元格列表,并handlePanning被称为无论我平移哪个方向。 我想要的是handlePanning只在水平平移而不垂直时才被调用。 希望能得到一些指导。

如何从Swift中的UIView中删除所有的手势识别器

我写了试图从给定的自定义UIViewtypes的所有子视图中删除所有手势识别器的Swift代码。 let mySubviews = self.subviews.filter() { $0.isKindOfClass(CustomSubview) } for subview in mySubviews { for recognizer in subview.gestureRecognizers { subview.removeGestureRecognizer(recognizer) } } 但是for recognizer器行会产生编译器错误: '[AnyObject]?' does not have a member named 'Generator' 我已经尝试更改for recognizer循环以for recognizer in enumerate(subview.gestureRecognizers)器,但会产生编译器错误: Type '[AnyObject]?!' Does not conform to protocol 'SequenceType' 我看到UIView的gestureRecognizers方法返回[AnyObject]?? ,而且我认为双重包装的回报价值正在让我失望。 谁能帮我? 更新:修改,编译代码是: if let recognizers = subview.gestureRecognizers { for […]

iOS:如何实现手写识别?

开始iOS开发,我希望在我的应用程序中实现手写识别。 我做了一个谷歌search,但我没有find任何教程在目标c实现文字手势 是否有任何基本的教程可用,实现文本手势… 例如:当用户在屏幕上写入A时,屏幕应显示A 有没有任何演示教程可用于这个项目?

UIGestureRecognizer拖动UIView

我试图构build一个GestureRecognizer从右到左拖动一个UIView 。 如果用户将视图拖动到屏幕的一半,视图将被自动拖拽到左边angular落放弃,但是如果用户没有拖动到屏幕的一半,它将返回到屏幕的右下angular。 这里输的很less,有什么教程或者什么的? 谢谢 编辑:inheritance人一些代码,它的UIImageView里面的UIScrollView ,我需要拖动整个滚动或只是其中的图像: _myScroll = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, self.window.bounds.size.width, self.window.bounds.size.height)]; [_myScroll setContentSize:CGSizeMake(self.window.bounds.size.width , 1300)]; _tutorial = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, self.window.bounds.size.width, 1300)]; [_tutorial setImage:[UIImage imageNamed:@"Default"]]; _tutorial.contentMode = UIViewContentModeScaleAspectFit; [_myScroll addSubview:_tutorial]; _tutorial.userInteractionEnabled = YES; UIPanGestureRecognizer * recognizer = [[UIPanGestureRecognizer alloc]initWithTarget:_tutorial action:@selector(handlePan:)]; [_tutorial addGestureRecognizer:recognizer]; [self.window addSubview:_myScroll]; 而我尝试拖动UIImageView – (IBAction)handlePan:(UIPanGestureRecognizer *)recognizer { CGPoint […]