美文网首页
第三方库页面返回后导航栏UINavigationBar颜色没有及

第三方库页面返回后导航栏UINavigationBar颜色没有及

作者: wangyu2488 | 来源:发表于2019-06-06 16:44 被阅读0次

2019年6月6日
第三方库页面返回后导航栏颜色没有及时修改
现象.跳转到图片库选择框图片后,将导航栏title设置成黄色,返回页面后再将title设置成黑色,没有马上生效解决
排查过程:普通A页面 设置红色 普通 B页面设置成黄色 ,A调转到B后 返回A都能正常显示红色
A

- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    UINavigationBar *navBar = self.navigationController.navigationBar;
    navBar.titleTextAttributes = @{ NSForegroundColorAttributeName: [UIColor redColor]};
}

B

- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    UINavigationBar *navBar = self.navigationController.navigationBar;
    navBar.titleTextAttributes = @{ NSForegroundColorAttributeName: [UIColor  yellowColor]};
}

原因:应该和库里面延迟有关系,因为自己简单的页面跳转不用延迟都正常。而且图片库里面断点调试感觉时序设置也正常。同事用延迟5s设置试了下,竟然成功了。 后来调试发现设置1s也正常。
解决:A页面设置1s延迟
B页面 #import "MWPhotoBrowser.h"


image.png

A页面 #import "HuPhotoBrowserViewController.h"


image.png
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        UINavigationBar *navBar = self.navigationController.navigationBar;
        navBar.titleTextAttributes = @{ NSForegroundColorAttributeName: [UIColor blackColor]};
    });

如果您发现本文对你有所帮助,如果您认为其他人也可能受益,请把它分享出去。

相关文章

网友评论

      本文标题:第三方库页面返回后导航栏UINavigationBar颜色没有及

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