OC

Knowledge OS
主帖 16 条回复

怎么停止触发touchesEnded touchesMoved

langhua9527 langhua9527 · 2013年11月21日 · 阅读 0 · 无人欣赏。
  • (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event;
  • (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event;
  • (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event;
  • (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event; 当手指在屏幕上面滑动的时候,我想停止这样的事件,应该怎么处理

我说一个场景吧,比如说微信的发送声音的功能,你按下开始录音,然后等到60秒的时候,就自动停止,无论用户的手指是否还在屏幕上。。

回复

16 条
#3
langhua9527
2013年11月21日

大家帮一下呀。。。。 我直接调touchesEnded 但是手指不松开的话。还会调touchesMoved

#4
nickel
2013年11月21日

!!!!!!! 你脑子哪里去了?

toucheesMoved里响应到没关系,在toucheesMoved通过判断一个标志位或状态来决定是否做事就好了。

#7
adad184
2013年11月22日
view.userInteractionEnabled = NO;
view.userInteractionEnabled = YES;

试试

#10
langhua9527
2013年11月22日

7楼 @adad184 view.userInteractionEnabled = NO; view.userInteractionEnabled = YES; 不行的。。还是会继续执行。。。

#11
gb18030
2013年11月22日

写个操作类,在开始录音的时候计时,循环更新,到了指定时长以后发送终止事件,结束录音

#12
langhua9527
2013年11月22日

11楼 @gb18030 我有NSTimer的,但是怎么终止事件?现在就是不知道怎么终止事情,我在NSTimer里面能检测录了多久,即时的录音大小的

#14
langhua9527
2013年11月22日

13楼 @tinyfool 好的。。。

@sycx 你肿么看 @nickel 大哥,你点播一下啥,我现在运到的问题是,如果用户手指放到屏幕不放,他会一直触发touchesMoved的,如果我直接调用touchesEnded,touchesMoved方法还是会执行,如果在touchesMoved加判断会使业务更加复杂。。我现在有足够的时间来处理的,我想用更好的方式来解决。。 我先试一下 view.userInteractionEnabled = NO; view.userInteractionEnabled = YES;

本帖有16个回复,因为您没有注册或者登录本站,所以只能看到本帖的10条回复。如果想看到全部回复,请注册或者登录本站。
登录 或者 注册
顶楼 / 底楼 / 首页