在我的应用程序中,我有一个 ibaction,在它里面我有 2 个不同的指令和一个“if”
if (i == 0) //do instruction set 1
if (i == 1) //do instruction set 2
// and everytime I push button i change from 0 to 1 or from 1 to 0
问题是,如果我反复按下这个 IbAction 的按钮,它就不能正常工作,因为之前的 ibaction 没有完成它的指令集 1
example = 按下按钮,它执行指令集 1,如果我再次按下按钮,它应该不会工作,因为它没有完成它的工作,我想等待指令集 1 结束以重复按下按钮。
你明白了吗?
最佳答案
假设您的类中有 BOOL workInProgress
变量:
- (IBAction)action {
if (!workInProgress) {
workInProgress = YES;
if (i == 0) {
// do something that in the end sets workInProgress to NO
} else if (i == 1) {
// do something else that in the end sets workInProgress to NO
}
}
}
关于IOS:IBAction 有两个 Action ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7806518/