Skip to content

Commit

Permalink
修复bug #76,修复可能提前触发viewDidLoad方法的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
QuintGao committed May 12, 2021
1 parent 2d8d4f6 commit 4afa11b
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 6 deletions.
2 changes: 1 addition & 1 deletion GKNavigationBar.podspec
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
14 changes: 10 additions & 4 deletions GKNavigationBar/NavigationBar/UIViewController+GKNavigationBar.m
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}

Expand Down Expand Up @@ -540,6 +544,8 @@ - (void)setupNavBarAppearance {
}

- (void)setupNavBarFrame {
// 防止在init方法中创建导航栏会提前触发viewDidLoad方法,所以做下判断
if (!self.isViewLoaded) return;
UIViewController *parentVC = self;
while (parentVC.parentViewController) {
parentVC = parentVC.parentViewController;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 {
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ configure.shiledGuestureVCs = @[NSClassFromString(@"TZPhotoPickerController"), @
<summary><font size=4>最近更新</font></summary>

```
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,可全局配置
Expand Down Expand Up @@ -264,4 +265,4 @@ configure.shiledGuestureVCs = @[NSClassFromString(@"TZPhotoPickerController"), @
&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp
<img src="https://upload-images.jianshu.io/upload_images/1598505-0be88fd4943d1994.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" width="200" height="200">

[回到顶部](#readme)
[回到顶部](#readme)

0 comments on commit 4afa11b

Please sign in to comment.