给NavigationController一个标签push属性记录控制器的push转态。
在自定义的NIPNavigationController的方法 - (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated
拦截是否正在push,如果是在push就直接return,否则跳转过来。
在代理方法- (void)navigationController:(UINavigationController *)navigationController didShowViewController:(UIViewController *)viewController animated:(BOOL)animated
该方法执行标志着push成功,成功之后重置push标签NO。
少BB直接上代码:
@interface NIPNavigationController ()<UINavigationControllerDelegate>
// 记录push转态
@property (nonatomic, assign,getter=isPushing) BOOL pushing;
@end
- (void)viewDidLoad {
[super viewDidLoad];
self.delegate = self;
}
- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated
{
if (self.isPushing == YES) {
return;
}else{
self.pushing = YES;
}
[super pushViewController:viewController animated:animated];
}
#pragma mark - UINavigationControllerDelegate
- (void)navigationController:(UINavigationController *)navigationController didShowViewController:(UIViewController *)viewController animated:(BOOL)animated
{
self.pushing = NO;
}