diff --git a/GKNavigationBar.podspec b/GKNavigationBar.podspec index a60f227..c02679f 100644 --- a/GKNavigationBar.podspec +++ b/GKNavigationBar.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'GKNavigationBar' - s.version = '1.5.5' + s.version = '1.5.6' s.license = 'MIT' s.summary = '自定义导航栏--导航栏联动' s.homepage = 'https://github.com/QuintGao/GKNavigationBar' @@ -8,7 +8,6 @@ Pod::Spec.new do |s| s.authors = { '高坤' => '1094887059@qq.com' } s.source = { :git => 'https://github.com/QuintGao/GKNavigationBar.git', :tag => s.version } s.ios.deployment_target = '9.0' - s.source_files = 'GKNavigationBar/GKNavigationBar.h' s.subspec 'NavigationBar' do |ss| diff --git a/GKNavigationBar/GestureHandle/UINavigationController+GKGestureHandle.m b/GKNavigationBar/GestureHandle/UINavigationController+GKGestureHandle.m index 6b80041..3463e8a 100644 --- a/GKNavigationBar/GestureHandle/UINavigationController+GKGestureHandle.m +++ b/GKNavigationBar/GestureHandle/UINavigationController+GKGestureHandle.m @@ -143,6 +143,8 @@ - (void)propertyChangeNotification:(NSNotification *)notification { if ([vc isKindOfClass:[UITabBarController class]]) return; if (!vc.navigationController) return; if (vc.navigationController != self) return; + // 修复非导航控制器子类时出现的问题 + if (vc.parentViewController != self) return; __block BOOL exist = NO; [GKGestureConfigure.shiledGuestureVCs enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { diff --git a/GKNavigationBar/NavigationBar/UIViewController+GKNavigationBar.m b/GKNavigationBar/NavigationBar/UIViewController+GKNavigationBar.m index f549b1b..25ae4db 100644 --- a/GKNavigationBar/NavigationBar/UIViewController+GKNavigationBar.m +++ b/GKNavigationBar/NavigationBar/UIViewController+GKNavigationBar.m @@ -52,6 +52,10 @@ - (void)gk_viewDidLoad { self.gk_navItemRightSpace = GKNavigationBarItemSpace; self.gk_disableFixNavItemSpace = [self checkFixNavItemSpace]; } + // 如果是根控制器,取消返回按钮 + if (self.navigationController && self.navigationController.childViewControllers.count <= 1) { + self.gk_navLeftBarButtonItem = nil; + } [self gk_viewDidLoad]; } @@ -554,19 +558,24 @@ - (void)setupNavBarAppearance { } - (void)setupNavBarFrame { + BOOL isNonFullScreen = NO; + CGFloat viewW = GK_SCREEN_WIDTH; + CGFloat viewH = GK_SCREEN_HEIGHT; // 防止在init方法中创建导航栏会提前触发viewDidLoad方法,所以做下判断 - if (!self.isViewLoaded) return; - UIViewController *parentVC = self; - while (parentVC.parentViewController) { - parentVC = parentVC.parentViewController; + if (self.isViewLoaded) { + UIViewController *parentVC = self; + // 找到最上层的父类 + while (parentVC.parentViewController) { + parentVC = parentVC.parentViewController; + } + viewW = parentVC.view.frame.size.width; + viewH = parentVC.view.frame.size.height; + if (viewW == 0 || viewH == 0) return; + + // 如果是通过present方式弹出且高度小于屏幕高度,则认为是非全屏 + isNonFullScreen = self.presentingViewController && viewH < GK_SCREEN_HEIGHT; } - CGFloat viewW = parentVC.view.frame.size.width; - CGFloat viewH = parentVC.view.frame.size.height; - if (viewW == 0 || viewH == 0) return; - - BOOL isNonFullScreen = self.presentingViewController && viewH < GK_SCREEN_HEIGHT; - CGFloat navBarH = 0.0f; if (GK_IS_iPad) { // iPad if (isNonFullScreen) { @@ -622,7 +631,10 @@ - (BOOL)navItemSpaceChangeIfNeeded { - (void)setBackItemImage:(UIImage *)image { if (!self.gk_NavBarInit) return; // 根控制器不作处理 - if (self.navigationController.childViewControllers.count <= 1) return; + if (self.navigationController && self.navigationController.childViewControllers.count <= 1) { + self.gk_navLeftBarButtonItem = nil; + return; + } if (!image) { if (self.gk_backStyle != GKNavigationBarBackStyleNone) { diff --git a/GKNavigationBarExample/GKNavigationBarExample/Demo/GKMainViewController.m b/GKNavigationBarExample/GKNavigationBarExample/Demo/GKMainViewController.m index ab9148f..a7541bf 100644 --- a/GKNavigationBarExample/GKNavigationBarExample/Demo/GKMainViewController.m +++ b/GKNavigationBarExample/GKNavigationBarExample/Demo/GKMainViewController.m @@ -167,7 +167,11 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath wxVC.modalPresentationStyle = UIModalPresentationFullScreen; [self presentViewController:wxVC animated:YES completion:nil]; }else if (indexPath.row == 11) { - UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:[GKPresentViewController new]]; + GKPresentViewController *presentVC = [GKPresentViewController new]; + presentVC.gk_navTitle = @"presentVC"; + + UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:presentVC]; + [self presentViewController:nav animated:YES completion:nil]; } } diff --git a/README.md b/README.md index 22e9a0c..f0cf737 100644 --- a/README.md +++ b/README.md @@ -206,6 +206,7 @@ configure.shiledGuestureVCs = @[NSClassFromString(@"TZPhotoPickerController"), @ 最近更新 ``` +1.5.6 - 2021.05.18 优化导航栏返回按钮及高度处理#77,手势处理优化 1.5.5 - 2021.05.14 修复导航栏间距失效的问题#76 1.5.4 - 2021.05.12 修复可能提前触发viewDidLoad方法的问题 1.5.3 - 2021.05.07 修复直接设置背景色无效的问题#71,#74,增加对非全屏的支持