Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

修改fd_prefersNavigationBarHidden未赋值时UINavigationController.navigationBarHidden设置的值无效的问题 #207

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,9 @@ - (void)fd_viewWillDisappear:(BOOL)animated

dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
UIViewController *viewController = self.navigationController.viewControllers.lastObject;
if (viewController && !viewController.fd_prefersNavigationBarHidden) {
if (viewController &&
viewController.fd_prefersNavigationBarHiddenObject &&
!viewController.fd_prefersNavigationBarHidden) {
[self.navigationController setNavigationBarHidden:NO animated:NO];
}
});
Expand All @@ -126,6 +128,10 @@ - (void)setFd_willAppearInjectBlock:(_FDViewControllerWillAppearInjectBlock)bloc
objc_setAssociatedObject(self, @selector(fd_willAppearInjectBlock), block, OBJC_ASSOCIATION_COPY_NONATOMIC);
}

- (NSNumber *)fd_prefersNavigationBarHiddenObject {
return objc_getAssociatedObject(self, _cmd);
}

@end

@implementation UINavigationController (FDFullscreenPopGesture)
Expand Down Expand Up @@ -188,7 +194,7 @@ - (void)fd_setupViewControllerBasedNavigationBarAppearanceIfNeeded:(UIViewContro
__weak typeof(self) weakSelf = self;
_FDViewControllerWillAppearInjectBlock block = ^(UIViewController *viewController, BOOL animated) {
__strong typeof(weakSelf) strongSelf = weakSelf;
if (strongSelf) {
if (strongSelf && viewController.fd_prefersNavigationBarHiddenObject) {
[strongSelf setNavigationBarHidden:viewController.fd_prefersNavigationBarHidden animated:animated];
}
};
Expand Down Expand Up @@ -261,7 +267,7 @@ - (void)setFd_interactivePopDisabled:(BOOL)disabled

- (BOOL)fd_prefersNavigationBarHidden
{
return [objc_getAssociatedObject(self, _cmd) boolValue];
return [self.fd_prefersNavigationBarHiddenObject boolValue];
}

- (void)setFd_prefersNavigationBarHidden:(BOOL)hidden
Expand Down