设为首页 加入收藏

TOP

iOS 防止UIButton重复点击
2019-08-31 00:21:47 】 浏览:27
Tags:iOS 防止 UIButton 重复 点击

 

使用UIButton的enabled或userInteractionEnabled

使用UIButton的enabled属性, 在点击后, 禁止UIButton的交互, 直到完成指定任务之后再将其enabled即可.

[btn addTarget:self action:@selector(nextStop:) forControlEvents:UIControlEventTouchUpInside];

 

- (void)nextStop:(UIButton *)sender {
    sender.enabled = NO;
    [self btnClicked];
}

 

- (void)btnClicked {

    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
    NSLog(@"btnClicked");
    btn.enabled = YES;
});
}

 

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇静态库打包——.a和.framework文件 下一篇iOS 12.1 跳转页面时 tabBar闪动

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目