From 4afa11b64dace55c4666753bb20e9415674b18ab Mon Sep 17 00:00:00 2001 From: QuintGao <1094887059@qq.com> Date: Wed, 12 May 2021 17:55:54 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dbug=20#76=EF=BC=8C=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E5=8F=AF=E8=83=BD=E6=8F=90=E5=89=8D=E8=A7=A6=E5=8F=91?= =?UTF-8?q?viewDidLoad=E6=96=B9=E6=B3=95=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- GKNavigationBar.podspec | 2 +- .../UIViewController+GKNavigationBar.m | 14 ++++++++++---- .../Demo/DemoVC/GKDemo000ViewController.m | 6 ++++++ README.md | 3 ++- 4 files changed, 19 insertions(+), 6 deletions(-) diff --git a/GKNavigationBar.podspec b/GKNavigationBar.podspec index e47c0db..7177e82 100644 --- a/GKNavigationBar.podspec +++ b/GKNavigationBar.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'GKNavigationBar' - s.version = '1.5.3' + s.version = '1.5.4' s.license = 'MIT' s.summary = '自定义导航栏--导航栏联动' s.homepage = 'https://github.com/QuintGao/GKNavigationBar' diff --git a/GKNavigationBar/NavigationBar/UIViewController+GKNavigationBar.m b/GKNavigationBar/NavigationBar/UIViewController+GKNavigationBar.m index 1ab2701..81ac7f9 100644 --- a/GKNavigationBar/NavigationBar/UIViewController+GKNavigationBar.m +++ b/GKNavigationBar/NavigationBar/UIViewController+GKNavigationBar.m @@ -44,10 +44,14 @@ + (void)load { } - (void)gk_viewDidLoad { - // 设置默认导航栏间距 - self.gk_navItemLeftSpace = GKNavigationBarItemSpace; - self.gk_navItemRightSpace = GKNavigationBarItemSpace; - self.gk_disableFixNavItemSpace = [self checkFixNavItemSpace]; + // bug fix #76,修改添加了子控制器后调整导航栏间距无效的bug + // 当创建了gk_navigationBar或者父控制器是导航控制器的时候才去调整导航栏间距 + if (self.gk_NavBarInit || [self.parentViewController isKindOfClass:[UINavigationController class]]) { + // 设置默认导航栏间距 + self.gk_navItemLeftSpace = GKNavigationBarItemSpace; + self.gk_navItemRightSpace = GKNavigationBarItemSpace; + self.gk_disableFixNavItemSpace = [self checkFixNavItemSpace]; + } [self gk_viewDidLoad]; } @@ -540,6 +544,8 @@ - (void)setupNavBarAppearance { } - (void)setupNavBarFrame { + // 防止在init方法中创建导航栏会提前触发viewDidLoad方法,所以做下判断 + if (!self.isViewLoaded) return; UIViewController *parentVC = self; while (parentVC.parentViewController) { parentVC = parentVC.parentViewController; diff --git a/GKNavigationBarExample/GKNavigationBarExample/Demo/DemoVC/GKDemo000ViewController.m b/GKNavigationBarExample/GKNavigationBarExample/Demo/DemoVC/GKDemo000ViewController.m index fde3e6e..3078ba4 100644 --- a/GKNavigationBarExample/GKNavigationBarExample/Demo/DemoVC/GKDemo000ViewController.m +++ b/GKNavigationBarExample/GKNavigationBarExample/Demo/DemoVC/GKDemo000ViewController.m @@ -63,6 +63,7 @@ - (void)viewDidLoad { self.gk_navShadowColor = [UIColor blackColor]; self.gk_backStyle = GKNavigationBarBackStyleWhite; self.gk_navItemRightSpace = 0; + self.gk_navItemRightSpace = 30; self.gk_navRightBarButtonItem = self.moreItem; self.leftPushSwitch.on = NO; @@ -79,6 +80,11 @@ - (void)viewDidLoad { self.gk_systemGestureHandleDisabled = YES; self.gk_popDelegate = self; + + UIViewController *vc = UIViewController.new; + vc.view.userInteractionEnabled = NO; + [self.view addSubview:vc.view]; + [self addChildViewController:vc]; } - (void)dealloc { diff --git a/README.md b/README.md index e324549..e6e97f3 100644 --- a/README.md +++ b/README.md @@ -206,6 +206,7 @@ configure.shiledGuestureVCs = @[NSClassFromString(@"TZPhotoPickerController"), @ 最近更新 ``` +1.5.4 - 2021.05.12 修复bug #76,修复可能提前触发viewDidLoad方法的问题 1.5.3 - 2021.05.07 修复直接设置背景色无效的问题#71,#74,增加对非全屏的支持 1.5.2 - 2021.04.06 增加协议方法,解决返回手势与WKWebView中的手势冲突问题 1.5.1 - 2021.03.09 返回手势优化,新增backStyle对应的image,可全局配置 @@ -264,4 +265,4 @@ configure.shiledGuestureVCs = @[NSClassFromString(@"TZPhotoPickerController"), @              -[回到顶部](#readme) \ No newline at end of file +[回到顶部](#readme)