草庐IT

Touchesbegan

全部标签

ios - TouchesBegan 未触发

我的Storyboard看起来像这样:Controllertop/bottomlayoutguideviewUIviewUIButtonUIImageView我的触摸功能是这样的:overridefunctouchesBegan(touches:Set,withEventevent:UIEvent?){print("touched")}当我触摸屏幕上除按钮所在位置以外的任何地方时,我的打印将被记录。UIImageView占据了整个屏幕,按钮只是中间的一个50x50像素的正方形。虽然当我点击按钮所在的顶部时,我所能看到的只是图像,但没有任何东西被触发。单击其他任何地方都会正确触发事件

ios - QLPreviewController 和 touchesBegan 方法

我在Swift中使用QLPreviewController。到目前为止,我能够通过将PDF添加到我的subview来显示PDF,而不是推送或呈现它。这允许我在文档底部有一个自定义工具栏,在顶部有一个自定义导航。现在我需要能够为我的QLPreviewControllerView使用touchesBegan方法。我正在做一些研究,结果我需要创建一个QLPreviewController的子类并覆盖viewDidAppear并添加一个UITapGestureRecognizer。我的问题是,如何创建QLPreviewController的子类?看起来像这样吗?importUIKitimpor

ios - touchesBegan 和 touchesMoved 没有在 UIView 上触发

我想要实现的目标:尝试抓取屏幕上当前触摸区域的坐标,并将接收到的坐标绘制到屏幕上。简而言之,一个基本的绘图应用程序,全部以编程方式编写(用于我自己的练习)。问题PaintingSubclass的touchesBegan和touchesMoved根本没有被调用。当前设置我有一个PaintingViewController然后我还有一个PaintingSubclass。PaintingViewController是一个UIViewController而PaintingSubclass是一个UIView。PaintingViewController创建一个PaintingSubclass的实

ios - CollectionView 与 touchesBegan 和 touchesEnded 方法中的动画混淆

我有一个CollectionView,其中包含带有ImageView的单元格。当用户按下ImageView(使用touchesBegan)时触发动画,当用户释放时触发另一个动画(使用touchesEnded)。仅当我按住单击然后松开(延迟单击)时,动画才能完美运行,但当我快速单击时,动画会像持续时间设置为0一样跳跃。我认为这个问题是因为CollectionView是ScrollView的子类,而scrollViews“通过启动计时器暂时拦截触摸事件,并在计时器触发之前查看触摸手指是否有任何移动。如果计时器在位置没有显着变化的情况下触发,ScrollView将跟踪事件发送到内容View的

ios - 覆盖 touchesBegan : Error - method does not override any method from superclass

我正在尝试覆盖UITapGestureRecognizer的自定义子类中的touchesBegan。代码如下。我从这里得到它:Howtoacceleratetheidentificationofasingletapoveradoubletap?.这是公认的答案,但我收到一个错误:方法不会覆盖其父类(superclass)中的任何方法。我已经检查过了,这似乎确实是touchesBegan的签名。帮忙?importUIKitclassUIShortTapGestureRecognizer:UITapGestureRecognizer{lettapMaxDelay:Double=0.3ove

ios - touchesBegan 未在 UICollectionViewController 中触发

我有一个UICollectionViewController类,它布置了一堆单元格。当用户触摸一个单元格时,我想使用touchesBegan方法来阻止新的触摸,直到第一次触摸完成它对单元格的选择。我尝试将以下代码放入我的ViewController中,但它从未被调用。overridefunctouchesBegan(touches:Set,withEventevent:UIEvent?){super.touchesBegan(touches,withEvent:event)print("touchesbegan")}但是,在我项目的其他地方,我有另一个类,它是UIViewControl

ios - 在 Swift 中使用 touchesBegan

我在使用函数touchesBegan时遇到了一些问题。问题是当touchesBegan执行时,图像人物跳到Main.storyboard开头定义的位置。这是我的代码:varlocation=CGPoint(x:0,y:0)@IBOutletweakvarperson:UIImageView!@IBOutletweakvarvalue:UILabel!overridefunctouchesBegan(touches:Set,withEventevent:UIEvent){lettouch:UITouch=touches.firstas!UITouchlocation=touch.loca

ios - touchesBegan 与 UITapGestureRecognizer

所以我正在使用swift制作一个spritekit游戏。我想知道哪种手势最适合使用?目前我有一个overridefunctouchesBegan处理所有的点击和一个UILongPressGestureRecognizer处理长点击/按住。所以你知道,点击按钮并跳跃英雄。长按会让英雄低头。出于某种原因,我的longPress函数并不总是被调用(有时您可以按住10次然后它停止被调用(无法识别),其他时候是5次,它会有所不同),这导致了昨天一整天都在尝试新事物并进行调查,这让我想到了这个问题。是使用touchesBegan还是将我所有的触摸调用移至由UITapGestureRecognize

ios - Swift:在 touchesBegan 中使用 switch 语句

我想在SKScene中清理我的touchesBegan(..)。我想做一个case语句而不是我的if..else链。但是,我在实现时遇到错误,这表明我不知道幕后是如何实现平等的。代码之前:overridefunctouchesBegan(touches:Set,withEventevent:UIEvent?){fortouch:AnyObjectintouches{letlocation=touch.locationInNode(self)ifself.nodeAtPoint(location)===playLabel{buildLevelSelect()}elseifself.nod

swift - 覆盖 UIGestureRecognizer touchesBegan

我有1个主视图和1个subview:主视图>subview我认为主视图正在“窃取”subview中的事件。例如,当我点击SubView时,只有MainViewGestureRecognizer启动。这是我的自定义GestureRecognizer(拦截每个触摸事件):importUIKitimportUIKit.UIGestureRecognizerSubclassclassMainGestureRecognizer:UIGestureRecognizer{overridefunctouchesBegan(touches:NSSet!,withEventevent:UIEvent!){