【开发笔记】监听webview的导航栏navigation返回按钮事件(分类)

【开发笔记】监听webview的导航栏navigation返回按钮事件(分类)_第1张图片

- (BOOL)navigationBar:(UINavigationBar *)navigationBar shouldPopItem:(UINavigationItem *)item {

if([self.viewControllers count] < [navigationBar.items count]) {

return YES;

}

BOOL shouldPop = YES;

UIViewController* vc = [self topViewController];

if([vc respondsToSelector:@selector(navigationShouldPopOnBackButton)]) {

shouldPop = [vc navigationShouldPopOnBackButton];

}

if(shouldPop) {

dispatch_async(dispatch_get_main_queue(), ^{

[self popViewControllerAnimated:YES];

});

} else {

// Workaround for back button transparent changes

for(UIView *subview in [navigationBar subviews]) {

if(subview.alpha < 1.) {

[UIView animateWithDuration:.25 animations:^{

subview.alpha = 1.;

}];

}

}

}

return NO;

}

你可能感兴趣的:(【开发笔记】监听webview的导航栏navigation返回按钮事件(分类))