美文网首页
UIImagePickerController调用后导航栏内容上

UIImagePickerController调用后导航栏内容上

作者: wustzhy | 来源:发表于2019-11-25 18:07 被阅读0次

    当调起UIImagePickerController拍照时,在 debug view Hierarchy中 可看到navigationBar整体上移了20,需要在合适的时机做一次恢复原位处理。

    解决思路:

    1. UIImagePickerController分类中,对disappear方法交换
    2. 获取上一个VC(即H5 wkwebview的VC)所在的nav
    3. 在disappear时nav.navigationBar.top = kStatusBarHeight;
    -(void)sx_viewWillDisappear:(BOOL)animated{
        sx_disableFixSpace = NO;
        [self sx_viewWillDisappear:animated];
        
        UINavigationController *topNav = [self getTopNavigationController];
        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
            //让状态栏显示
            [topNav setNeedsStatusBarAppearanceUpdate];
            //topNav.navigationBar.top = kStatusBarHeight;
            if ([topNav.viewControllers.lastObject isKindOfClass:[UITabBarController class]]) {
                UITabBarController *tabbarC = topNav.viewControllers.lastObject;
                UINavigationController * nav = tabbarC.selectedViewController;
                nav.navigationBar.top = kStatusBarHeight;
            }
        });
    }
    

    fixed: H5调系统拍照 导航栏上移20 【待研究更佳方式】

    相关文章

      网友评论

          本文标题:UIImagePickerController调用后导航栏内容上

          本文链接:https://www.haomeiwen.com/subject/ldvjwctx.html