NavigationController

1.导航控制器遇到的bug

今天遇到个很有意思的导航栏bug,之前没时间记录,趁着清明放假,把问题记录下来,然后欢迎大家和我探讨究竟问题在哪,自己写了一个小例子

github传送门

问题的发生是这样的

VC4的代码里面

<figure class="highlight plain" style="display: block; margin: 20px 0px; overflow: auto; padding: 0px; font-size: 13px; color: rgb(77, 77, 76); background: rgb(247, 247, 247); line-height: 1.6; border-radius: 1px; font-family: Lato, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;">

<pre style="overflow: auto; font-family: consolas, Menlo, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, monospace; font-size: 13px; margin: 0px; padding: 10px; color: rgb(134, 145, 148); background: rgb(239, 242, 243); line-height: 1.6; border: none; text-align: right;">1
2
</pre>
<pre style="overflow: auto; font-family: consolas, Menlo, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, monospace; font-size: 13px; margin: 0px; padding: 10px; color: rgb(77, 77, 76); background: rgb(247, 247, 247); line-height: 1.6; border: none; width: 335px;">self.title = @"成功"
self.backgroundColot = [UIColor whiteColor];
</pre>

</figure>

正常运行是没有问题的,你会看到VC4是你想要的效果,就是上图的V1->V2->V4路线
然而把Appdelegate
这段注释打开后运行你就会发现

<figure class="highlight plain" style="display: block; margin: 20px 0px; overflow: auto; padding: 0px; font-size: 13px; color: rgb(77, 77, 76); background: rgb(247, 247, 247); line-height: 1.6; border-radius: 1px; font-family: Lato, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;">

<pre style="overflow: auto; font-family: consolas, Menlo, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, monospace; font-size: 13px; margin: 0px; padding: 10px; color: rgb(134, 145, 148); background: rgb(239, 242, 243); line-height: 1.6; border: none; text-align: right;">1
</pre>
<pre style="overflow: auto; font-family: consolas, Menlo, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, monospace; font-size: 13px; margin: 0px; padding: 10px; color: rgb(77, 77, 76); background: rgb(247, 247, 247); line-height: 1.6; border: none; width: 614px;">//[[[[UIApplication sharedApplication] delegate] window] addSubview:self.vc3.view];
</pre>


</figure>

这段注释打开后运行你就会发现

V4的导航栏标题是V2的标题,而且不管你怎么初始化V4的导航栏做变化,包括更改左右按钮,中心视图都没有用,都是沿用V2的导航栏,而V2push的所有包括V4在内的控制器,都是用的V2导航栏

Interesting

这个问题当时我不知道是add在window的影响,找了挺长时间的,现在发现了是这个问题,就先记录下来,花时间研究一下(当然也有可能懒得研究),所以先写下来共勉,有兴趣的小伙伴可以一起研究,讨论结果,会继续在这里公布最新成果,个人认为应该是导航控制器navgationController的问题

今天给大家的分享就到这吧!有收获,或者喜欢小编的可以关注加小编的微信同时也欢迎大家加入或小编的iOS交流群687528266,点击链接加入群聊【iOS软件开发学习交流】:https://jq.qq.com/?_wv=1027&k=53OMouY,相互学习!大家一起交流成长!!

如果需要以下书籍,加QQ群687528266免费分享

猜你喜欢

转载自blog.csdn.net/ping20/article/details/80685613