【发布时间】:2016-05-20 08:34:32
【问题描述】:
在我的应用程序中有时我会收到此错误,因为 UI 冻结并且用户多次点击按钮:
"多次推送同一个视图控制器实例不是 支持”
我试过这个:
How to prevent multiple event on same UIButton in iOS?
它就像一个魅力,但如果我的标签栏有超过 5 个元素,如果我点击显示大于 5 的元素的按钮,则更多的按钮从左到右动画。
有没有其他不使用动画的简单方法来防止双标签?
这是我正在使用的代码:
- (IBAction)btnAction:(id)sender {
UIButton *bCustom = (UIButton *)sender;
bCustom.userInteractionEnabled = NO;
[UIView animateWithDuration:1.0 delay:0.0 options:UIViewAnimationOptionAllowAnimatedContent animations:^{
[self selectTabControllerIndex:bCustom.tag];
} completion:^(BOOL finished){
bCustom.userInteractionEnabled = YES;
}];
}
【问题讨论】:
-
试试这个答案,它适用于单元格中的计时器:stackoverflow.com/a/22999019/4833705
标签: ios objective-c uibutton