V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
iOS 开发实用技术导航
NSHipster 中文版
http://nshipster.cn/
cocos2d 开源 2D 游戏引擎
http://www.cocos2d-iphone.org/
CocoaPods
http://cocoapods.org/
Google Analytics for Mobile 统计解决方案
http://code.google.com/mobile/analytics/
WWDC
https://developer.apple.com/wwdc/
Design Guides and Resources
https://developer.apple.com/design/
Transcripts of WWDC sessions
http://asciiwwdc.com
Cocoa with Love
http://cocoawithlove.com/
Cocoa Dev Central
http://cocoadevcentral.com/
NSHipster
http://nshipster.com/
Style Guides
Google Objective-C Style Guide
NYTimes Objective-C Style Guide
Useful Tools and Services
Charles Web Debugging Proxy
Smore
iyeatse
V2EX  ›  iDev

iOS 系统设置关于 UINavigationBar 的一个 bug

  •  
  •   iyeatse ·
    yeatse · 2016-07-14 11:25:14 +08:00 · 7062 次点击
    这是一个创建于 2835 天前的主题,其中的信息可能已经有所发展或是发生改变。

    https://youtu.be/JF_ZzJJ2AOI

    不知道什么时候开始出现的,至少 iOS 9 的时候就有了,刚刚试了最新版的 iOS 10 该 bug 依然存在,出现几率 100%。

    讲道理我对 Apple 的导航控制器的一些设计挺不解的。明明在 iOS 7 中 Apple 都用 [UIViewController preferredStatusBarStyle] 替代全局的 [UIApplication statusBarStyle] 了,但是对于 Navigation Bar 的配置至今依然要修改全局的 Navigation Bar ,导致很多关于自定义导航栏的需求都不能优雅地实现。
    18 条回复    2016-07-21 23:27:02 +08:00
    queuey
        1
    queuey  
       2016-07-14 11:27:09 +08:00
    图看不到
    402645707
        2
    402645707  
       2016-07-14 11:30:09 +08:00
    坚守 Ios8.3 不升
    看来我没做错
    iyeatse
        3
    iyeatse  
    OP
       2016-07-14 11:30:22 +08:00
    @queuey 是 youtube 的视频
    ma125125t
        4
    ma125125t  
       2016-07-14 11:36:15 +08:00
    一看就是 [navigationController setNavigationBarHidden:YES animated:YES] 导致的。被坑过。
    a412739861
        5
    a412739861  
       2016-07-14 11:42:03 +08:00
    这个 bug 一直有………… push 进去的界面 hide 就有问题……好像跟左滑返回有关
    xi_lin
        6
    xi_lin  
       2016-07-14 12:26:39 +08:00
    所以我的项目里都弃 UINavigationController 自带的 navigationBar 而新建一个自己控制。。
    loveuqian
        7
    loveuqian  
       2016-07-14 13:20:54 +08:00 via iPhone
    @xi_lin 所以你的所有 view 的 navbar 都是 hidden ?然后自建一个 64 高的 view 为 navbar 嘛?
    iyeatse
        8
    iyeatse  
    OP
       2016-07-14 14:22:29 +08:00
    @loveuqian 我就是这么干的。。然后 automaticallyAdjustsScrollViewInsets 以及 topLayoutGuide 相关属性都不能用了,滑动返回的手势也要自己做,无奈产品需求太奇葩= =,这么干至少过渡动画是正常了。。
    MountainRain
        9
    MountainRain  
       2016-07-14 14:48:52 +08:00
    https://github.com/ltebean/LTNavigationBar 我一般是用这个来解决隐藏和显示的
    kitalphaj
        10
    kitalphaj  
       2016-07-14 15:26:51 +08:00
    Navigation bar 一堆坑。。。什么返回按钮文字,导航栏背景图,透明度。。。感觉设计这块的那人一开始想得很好,各种抽象各种支持,结果发现自己能力有限无法做到面面俱到。。。
    jjgod
        11
    jjgod  
       2016-07-14 15:44:38 +08:00
    radar#?
    xi_lin
        12
    xi_lin  
       2016-07-14 18:46:49 +08:00
    @loveuqian 嗯,是的。就是还要封装一些相关处理。
    fhefh
        13
    fhefh  
       2016-07-14 21:11:18 +08:00
    mark
    mmkkyang
        14
    mmkkyang  
       2016-07-14 23:24:24 +08:00
    加上 StatusBar 就更可喜了。
    tzheng
        15
    tzheng  
       2016-07-15 06:53:08 +08:00
    其实没有看出来最后一步是点了什么让 navbar 消失的,还是用了滑动的 gesture ?有了视频又有重现步骤到 bugreport.apple.com 发是最好的啦

    @kitalphaj 建议意见也是可以发到上面这个地址的
    bbbb
        16
    bbbb  
       2016-07-15 09:45:34 +08:00
    这个 bug 整个系统都存在呀。。。开发中遇到过,用第三方隐藏就好了。。。
    kitalphaj
        17
    kitalphaj  
       2016-07-19 09:14:37 +08:00
    @iyeatse

    In iOS 10, UIKit has updated and unified background management for UINavigationBar, UITabBar, and UIToolbar. In particular, changes to background properties of these views (such as background or shadow images, or setting the bar style) may kick off a layout pass for the bar to resolve the new background appearance.
    In particular, this means that attempts to change the background appearance of these bars inside of -[UIView layoutSubviews], -[UIView updateConstraints], -[UIViewController willLayoutSubviews], -[UIViewController didLayoutSubviews], - [UIViewController updateViewConstraints], or any other method that is called in response to layout may result in a layout loop.
    In some cases you can break these layout loops by ensuring that you always use the same object instance when objects (such as UIImage or UIColor) are required. But in general you should avoid doing this.
    Because all appearance parameters are now resolved at one time, there may be some cases where your bar's appearance has changed. In general, best results are obtained by specifying as little as possible for customizing your bar. For example, if you are specifying a barTintColor value and specifying an empty UIImage object for the backgroundImage property (as is the case when you call [UIImage new], for example) then you should get better results by specifying only the barTintColor. Any changes you make to resolve these issues in iOS 10 should also work correctly in iOS 9 — if this is not the case, please report bugs with a sample project and a screenshot indicating what the bars should look like.

    这是刚出的 beta 3 的 release note 。似乎换了架构,没准这个问题有机会彻底解决。
    Dadz
        18
    Dadz  
       2016-07-21 23:27:02 +08:00
    被坑两天了。都特么赖 UIKIT
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5685 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 02:37 · PVG 10:37 · LAX 19:37 · JFK 22:37
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.