segue返回后,iOS UINavigationBar按钮仍然褪色 [英] iOS UINavigationBar button remains faded after segue back

查看:118
本文介绍了segue返回后,iOS UINavigationBar按钮仍然褪色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序中,我有多个视图控制器,大多数都有右侧 UIBarButtonItem ,附加了直接的showsegue操作。

In my app I have multiple view controllers, and most have a right-hand-side UIBarButtonItem with direct "show" segue actions attached.

隐藏到另一个视图然后按'<返回'按钮,原始按钮项目仍然淡出,但仍然可以使用。

Having segued to another view and then pressed the '< Back' button, the original button item remains faded out, although still otherwise usable.

这似乎只发生在iOS 11.2下。

This only appears to happen under iOS 11.2.

我看不到任何可能这样做的设置,并且在至少一个发生这种情况的情况下,没有特定的segue展开,也没有 viewDidAppear 处理。我发布了一些代码,但AFAICS只是默认 UINavigationBar 行为。

I can't see any setting that could be doing this, and in at least one of the cases where this happens there's no specific segue unwinding nor viewDidAppear handling. I'd post some code, but AFAICS it's all just default UINavigationBar behaviour.

推荐答案

这是iOS 11.2中的一个错误,因为 UIBarButtonItem 在导航后保持突出显示,并且在其他视图控制器弹出后不会返回到正常状态。

This is a bug in iOS 11.2 and happens because the UIBarButtonItem stays highlighted after navigation and does not return to its normal state after the other view controller pops.

要避免此行为,


  1. 使用 UIBarButtonItem 带有 UIButton 作为自定义视图

禁用和重新启用 viewWillDisappear(_:)中的小节按钮项(虽然这会导致按钮立即显示,但请使用 matt的解决方案以避免这种情况):

disable and re-enable the bar button item in viewWillDisappear(_:) (although this causes the button to appear immediately, use matt's solution to avoid this):


barButtonItem.isEnabled = false
barButtonItem.isEnabled = true


这篇关于segue返回后,iOS UINavigationBar按钮仍然褪色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆