我有一个 UITableView:
单元格 1:按钮 1->按下以查看 Controller A
Cell 2: Button 2->push to view controller B
它工作正常。但是,当我尝试同时按住和按下两个按钮时,我的应用会收到以下警告:
nested push animation can result in corrupted navigation bar. Finishing up a navigation transition in an unexpected state. Navigation Bar subview tree might get corrupted.
我应该如何禁用单元格上的多次单击按钮?
最佳答案
你只需要在推送到另一个 View Controller 时禁用按钮。
您可以创建 UINavigationController
类别以推送到另一个 View Controller 。确保在返回当前 viewController 之前启用按钮
@interface UINavigationController (CompletionHandler)
- (void)pushViewController:(UIViewController *)viewController
animated:(BOOL)animated
completion:(void (^)(void))completion;
@end
@implementation UINavigationController (CompletionHandler)
- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated completion:(void (^)(void))completion {
[CATransaction begin];
[CATransaction setCompletionBlock:completion];
[self pushViewController:viewController animated:animated];
[CATransaction commit];
}
@end
调用下面的代码推送到另一个ViewController
[self.navigationController pushViewController:ControllerObj animated:YES completion:^{
btn.userInteractionEnabled = NO; // Your Button Object
NSLog(@"COMPLETED");
}];
关于ios - 如何禁用多次单击按钮?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30251663/