我想防止在同一个UIButton上连续多次点击.
我尝试使用enabled和exclusivetouch属性,但它不起作用.如:
-(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; }
解决方法
你正在做的是,你只需在块外设置启用开/关.这是错误的,它执行一旦这个方法将调用,因此它不会禁用按钮,直到完成块将调用.相反,一旦动画完成,你应该重新启用它.
-(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. }
哦,是的,而不是真假,是和否看起来不错.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。