如何防止iOS中同一个UIButton上的多个事件?

如何防止iOS中同一个UIButton上的多个事件?,第1张

概述我想防止在同一个UIButton上连续多次点击. 我尝试使用enabled和exclusiveTouch属性,但它不起作用.如: -(IBAction) buttonClick:(id)sender{ button.enabled = false; [UIView animateWithDuration:1.0 delay:0.0 options:UIViewAnimationOp 我想防止在同一个UIbutton上连续多次点击.

我尝试使用enabled和exclusivetouch属性,但它不起作用.如:

@H_403_4@-(IBAction) buttonClick:(ID)sender{ button.enabled = false; [UIVIEw animateWithDuration:1.0 delay:0.0 options:UIVIEwAnimationoptionAllowAnimatedContent animations:^{ // code to execute } completion:^(BOol finished){ // code to execute }]; button.enabled = true;}解决方法 你正在做的是,你只需在块外设置启用开/关.这是错误的,它执行一旦这个方法将调用,因此它不会禁用按钮,直到完成块将调用.相反,一旦动画完成,你应该重新启用它. @H_403_4@-(IBAction) buttonClick:(ID)sender{ button.enabled = false; [UIVIEw animateWithDuration:1.0 delay:0.0 options:UIVIEwAnimationoptionAllowAnimatedContent animations:^{ // code to execute } completion:^(BOol finished){ // code to execute button.enabled = true; //This is correct. }]; //button.enabled = true; //This is wrong.}

哦,是的,而不是真假,是和否看起来不错. 总结

以上是内存溢出为你收集整理的如何防止iOS中同一个UIButton上的多个事件?全部内容,希望文章能够帮你解决如何防止iOS中同一个UIButton上的多个事件?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1105784.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-28
下一篇 2022-05-28

发表评论

登录后才能评论

评论列表(0条)

保存