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

2016-07-14 11:25:14 +08:00
 iyeatse
<amp-youtube data-videoid="JF_ZzJJ2AOI" layout="responsive" width="480" height="270"></amp-youtube>
<amp-youtube data-videoid="JF_ZzJJ2AOI" layout="responsive" width="480" height="270"></amp-youtube>
不知道什么时候开始出现的,至少 iOS 9 的时候就有了,刚刚试了最新版的 iOS 10 该 bug 依然存在,出现几率 100%。

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

@kitalphaj 建议意见也是可以发到上面这个地址的
bbbb
2016-07-15 09:45:34 +08:00
这个 bug 整个系统都存在呀。。。开发中遇到过,用第三方隐藏就好了。。。
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
2016-07-21 23:27:02 +08:00
被坑两天了。都特么赖 UIKIT

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/292414

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX