UIViewController-BackButtonHandler
UIViewController-BackButtonHandler copied to clipboard
A little problem for custom back button
If custom back button is used, pressing back button may cause redisplay of default back button(iOS 8.1, iPhone6). So for this case, "subview.alpha = 1.;" is not necessary.
Probably this is fixed by 834617d ?
因为是自定义按钮 所以不会调用- (BOOL)navigationBar:(UINavigationBar *)navigationBar shouldPopItem:(UINavigationItem *)item 所以你的框架就没有用了
I had the same issue this was the solution for me. When using custom image for your back button, iOS does not remove the actual back button, it only fades to to alpha 0. And the interception function was re-seting the back button to 1.
If you customized the back button globally like this:
UIImage *backbutton= [[UIImage tintableImageNamed:@"back-button.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0, 0, 0) resizingMode:UIImageResizingModeTile];
[[UIBarButtonItem appearance] setBackButtonBackgroundImage:backbutton forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
Then you should add this in :
- (BOOL)navigationBar:(UINavigationBar *)navigationBar shouldPopItem:(UINavigationItem *)item
BOOL hasCustomImage = [[UIBarButtonItem appearance] backButtonBackgroundImageForState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
if (!hasCustomImage) {
// Workaround for iOS7.1. Thanks to @boliva - http://stackoverflow.com/posts/comments/34452906
for(UIView *subview in [navigationBar subviews]) {
if(subview.alpha < 1.) {
[UIView animateWithDuration:.25 animations:^{
subview.alpha = 1.;
}];
}
}
}
Can you confirm that this works for you ?