Skip to content

Commit

Permalink
导航栏处理优化#77,手势处理优化
Browse files Browse the repository at this point in the history
  • Loading branch information
QuintGao committed May 18, 2021
1 parent f2ed460 commit c66e321
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 14 deletions.
3 changes: 1 addition & 2 deletions GKNavigationBar.podspec
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
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'
s.social_media_url = 'https://github.com/QuintGao'
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|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
34 changes: 23 additions & 11 deletions GKNavigationBar/NavigationBar/UIViewController+GKNavigationBar.m
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}

Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}
}
Expand Down
1 change: 1 addition & 0 deletions 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.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,增加对非全屏的支持
Expand Down

0 comments on commit c66e321

Please sign in to comment.