iOS 防止用户重复点击按钮多次请求

/** 点击了导航栏右边按钮点击事件 */
- (void)rightItemClicked {
    
    self.rightItem.enabled = NO;
    [self performSelector:@selector(changeButtonStatus) withObject:nil afterDelay:2.0f];//防止用户重复点击
    //手动刷新
    [self loadData];
}

//防止用户重复点击
-(void)changeButtonStatus{
    self.rightItem.enabled = YES;
}

 

/** 防止用户多次点击cell */

@property (nonatomic, assign) BOOL isSelect;


- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ //防止重复点击 if (self.isSelect == false) { self.isSelect = true; //在延时方法中将isSelect更改为false [self performSelector:@selector(repeatDelay) withObject:nil afterDelay:0.5f]; // TODO:在下面实现点击cell需要实现的逻辑就可以了 } } - (void)repeatDelay{ self.isSelect = false; }

 

posted on 2022-01-24 16:58  高彰  阅读(502)  评论(0编辑  收藏  举报

导航