Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TZPhotoPreviewController navBar异常,没隐藏成功—— FDFullscreenPopGesture的bug,内有绕过方案 #652

Closed
FdhWait opened this issue Nov 22, 2017 · 12 comments

Comments

@FdhWait
Copy link

FdhWait commented Nov 22, 2017

正常从相册的列表去查看大图
image

@FdhWait
Copy link
Author

FdhWait commented Nov 22, 2017


image

@FdhWait
Copy link
Author

FdhWait commented Nov 22, 2017


image

@banchichen
Copy link
Owner

Hi, 你这是Demo吗,Demo里我这是正常的...

@FdhWait
Copy link
Author

FdhWait commented Nov 23, 2017

不是demo 正常集成的 找不到问题原因在哪里

@banchichen
Copy link
Owner

@FdhWait 可以提取一下,制作一个能复现该问题的Demo吗,通过网盘分享给我,我来复现一下

@FdhWait
Copy link
Author

FdhWait commented Nov 24, 2017

@banchichen 明天休息的时候有时间我弄一下

@FdhWait
Copy link
Author

FdhWait commented Nov 24, 2017

@banchichen 找到问题原因了 是因为工程中 加了 FDFullscreenPopGesture 侧滑返回的

@FdhWait
Copy link
Author

FdhWait commented Nov 24, 2017

@banchichen 已解决 一直忘了加侧滑的了哈, 加入self.fd_prefersNavigationBarHidden = YES;就可以了

@banchichen
Copy link
Owner

解决了就好👍

@banchichen
Copy link
Owner

这个是FDFullscreenPopGesture的问题,它hook了所有控制器的viewWillDisappear判断了如果fd_prefersNavigationBarHidden是NO就显示导航栏...

会影响所有未设置fd_prefersNavigationBarHidden为YES但需要隐藏导航栏的控制器...

如果大家不想改动库内部代码,可以参考下面的做法用KVO避免这个问题:

- (void)pushTZImagePicker {
    TZImagePickerController *tzImagePicker = [[TZImagePickerController alloc] initWithMaxImagesCount:9 delegate:self];
    [self presentViewController:tzImagePicker animated:YES completion:nil];
    
    // 监听TZImagePickerController导航栏的显示与否
    [tzImagePicker addObserver:self forKeyPath:@"navigationBar.hidden" options:NSKeyValueObservingOptionNew context:nil];
}

- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary<NSKeyValueChangeKey,id> *)change context:(void *)context {
    if ([keyPath isEqualToString:@"navigationBar.hidden"] && [object isKindOfClass:[TZImagePickerController class]]) {
        TZImagePickerController *tzImagePicker = (TZImagePickerController *)object;
        // 当前在预览页面,且导航栏显示着(被FD等第三方库打开了),再隐藏下导航栏
        if ([tzImagePicker.topViewController isKindOfClass:[TZPhotoPreviewController class]] && [change[NSKeyValueChangeNewKey] intValue] == 0) {
            dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
                [tzImagePicker setNavigationBarHidden:YES];
            });
        }
    }
}

@banchichen banchichen changed the title TZPhotoPreviewController navBar 显示异常 TZPhotoPreviewController navBar异常,没隐藏成功—— FDFullscreenPopGesture的bug,内有绕过方案 Nov 16, 2018
@YangYueFan
Copy link

牛逼 解决了我 在iOS13中选择图片,预览,返回后状态栏高度变成0 和navBar挤在一起的问题

@coderlinxx
Copy link

bravo bravo 确实是这个原因

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants