jjzjj

touchesended

全部标签

ios - 调用 touchescancelled 而不是 touchesended

我正在尝试在触摸时点亮View并在触摸结束时取消点亮。在执行此操作时,我注意到当我从View中抬起手指时,-(void)touchesEnded:(NSSet*)toucheswithEvent:(UIEvent*)event方法未被调用,而是-在View上调用(void)touchesCancelled:(NSSet*)toucheswithEvent:(UIEvent*)event方法。这是正常行为吗?我认为如果由于低内存警告等系统问题而取消触摸,则会调用touchesCancelled。我通过使用touchesCancelled完成了我的工作,但我想知道为什么它没有正确调用tou

ios - 如何使用 touchesBegan 和 touchesEnded 检测点击手势

我创建了一个自定义控件,它直接派生自UIView类。现在我想在用户点击我View的特定部分时执行一个操作。所以我重写了方法touchesBegan、touchesEnded和touchesCancelled。问题是,如果我只是点击显示屏,方法touchesEnded永远不会被调用。touchesCancelled方法被称为它的替代品。touchesEnded仅在我执行某些手势(滑动、移动等)时被调用。我是否需要以任何方式配置我的View以启用点击手势?我的代码:-(void)touchesBegan:(NSSet*)toucheswithEvent:(UIEvent*)event{NS

ios - Spritekit touchesEnded 滞后

我正在使用spritekit制作游戏,触摸开始和触摸结束之间有明显的100-200毫秒延迟。有什么办法可以加快速度吗?我需要使用touchesended(计算用户触摸的起点和终点之间的矢量射线。-(void)touchesBegan:(NSSet*)toucheswithEvent:(UIEvent*)event{for(UITouch*touchintouches){CGPointlocation=[touchlocationInNode:self];touch_start_pt=location;}touching=true;}-(void)touchesEnded:(NSSet*

ios - touchesEnd 未被调用位 touchesBegin 和 touchesMoved 确实被调用

我正在尝试在ios中进行拖动。如果拖动移动的距离很短,我将通过比较起始x、y(从touchesBegan开始)与touchesEnd中的x、y来将拖动计为单击事件。似乎touchesEnd永远不会被调用。我设置了一个断点来验证它,断点从未消失。code:-(void)touchesBegan:(NSSet*)toucheswithEvent:(UIEvent*)event{NSUIntegertouchCount=[touchescount];NSUIntegertapCount=[[touchesanyObject]tapCount];[selfUpdateDrag];}-(void

ios - 调用 touchesEnded : when tapped but not swiped

我想在用户点击屏幕上的特定位置而不是在用户在屏幕上滑动时调用touchesEnded:方法。我怎样才能做到这一点?从调试来看,touchesEnded:似乎在用户点击或滑动时被调用。我想我可以添加一个局部变量来跟踪用户是否像下面那样滑动,但我认为有更强大的方法来处理这个问题:BOOLtrackSwipe=NO;//Localvariable-(void)touchesMoved:(NSSet*)toucheswithEvent:(UIEvent*)event{trackSwipe=YES;//dosomething}-(void)touchesEnded:(NSSet*)touches

iphone - 覆盖方法语法 ios

我正在尝试像这样覆盖我的cellForRowAtIndexPath方法中的一个方法cell.customSwitch{-(void)touchesEnded:(NSSet*)toucheswithEvent:(UIEvent*)event{[supertouchesEnded:toucheswithEvent:event];NSLog(@"customSwitchtouchesended");}};但是这不起作用(我通常是Java人:P)。任何帮助将不胜感激! 最佳答案 Objective-C和Java之间有很多相似之处,但不是其中

ios - 未调用 TouchesEnded 和 TouchesCancelled

好的,我在Xcode4.5/iOS6上使用选项卡式应用程序模板测试了以下内容。创建了一个选项卡式应用程序。创建了一个名为SampleButton的UIButton子类并实现了以下方法:-(void)touchesBegan:(NSSet*)toucheswithEvent:(UIEvent*)event{[supertouchesBegan:toucheswithEvent:event];}-(void)touchesCancelled:(NSSet*)toucheswithEvent:(UIEvent*)event{[supertouchesCancelled:toucheswith

ios - 如何使用 UIBezierpath 在 touchesEnded 的屏幕上画一个点

有人可以告诉我如何使用UIBezierpath绘制一个点吗?我可以使用UIBezierpath画一条线,但如果我移开手指再放回去,然后再移开,屏幕上就不会绘制任何东西。-(void)touchesEnded:(NSSet*)toucheswithEvent:(UIEvent*)event{UITouch*touch=[touchesanyObject];CGPointp=[touchlocationInView:self];[pPathmoveToPoint:p];[pPathstroke];[selfsetNeedsDisplay];}-(void)drawRect:(CGRect)

ios - 第二次呈现场景时不调用 SKScene touchesEnded

我有一个带有主菜单的SpriteKit游戏。菜单标签在touchesEnded上触发。这在第一次启动游戏时工作正常。然后,第一关结束后,再次呈现主菜单。这次没有触发touchesEnded!!!我尝试显示另一个菜单(选项菜单),但同样的事情发生了。当我第一次展示它时它有效(我的意思是touchesEnded)但第二次展示它时没有调用touchesEnded!!有人遇到过这个吗? 最佳答案 导致问题的原因是在我的游戏关卡中我有一个UITapGestureRecognizer。我应该执行以下操作:myTapRecognizer.canc

Swift 定时器检查 TouchesEnded

很抱歉让我感到尴尬,但请问我能否获得有关如何执行此操作的完整代码:我希望在我的游戏中每发射一颗子弹后延迟1秒,以防止子弹垃圾邮件。如果可能的话,不要像我在touchesEnded中那样为子弹生成创建单独的函数。所以点击,射击,等待。点击,射击,等待。在等待的过程中,如果屏幕被点击,什么也不会发生。谢谢,对不起,我是初学者guardlettouch=touches.firstelse{return}lettouchLocation=touch.location(in:self)//Setupinitiallocationofbulletandpropertiesletbullet=SKS