每次重绘时都会重新应用 UIBarButtonItem 图像插入?
我有一个 UIToolbar
作为我的 UINavigationController
的一部分。 UIToolbar
上有几个普通的 UIBarButtonItem
,每个都有我在界面生成器中指定的自定义图像。我的图像并不像我想要的那样居中,因此我在尺寸检查器的顶部应用了一个小图像插图。
左边的按钮没有内嵌,右边的按钮在 6 的上方有一个内嵌。
但是,似乎每当重新绘制工具栏时(从模态视图返回后,或隐藏和取消隐藏工具栏),带有插图的按钮就会越来越小,就像插图每次都被重新应用一样。所以它看起来像这样:
这是 iOS 中的错误,还是我做错了什么?
先感谢您。
I have a UIToolbar
as part of my UINavigationController
. The UIToolbar
has several plain UIBarButtonItem
s on it, each with custom images I specified in interface builder. My images don't fit quite as centered as I'd like, so I apply a small image inset to the top in the size inspector.
The button on the left has no inset, and the one on the right has an inset on the top of 6.
However, it seems that whenever the toolbar is redrawn (after coming back from a modal view, or hiding and unhiding the toolbar), the button with an inset shrinks more and more—like the inset is getting reapplied every time. So it looks like this:
Is this a bug in iOS, or am I doing something wrong?
Thank you in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我在使用 iPhone 应用程序时遇到了同样的问题,特别是从模态视图返回时。我处理它的方法是在模态被解雇时触发 NSNotification,有问题的视图会听取。有点像这样。
然后将其注册到您的其他类中以触发您的方法。
I had this same problem with an iPhone app specifically when returning from a modal view. The way I handled it was to fire off an NSNotification when the Modal is being dismissed that the views which were having issues would listen to. Kinda Like this.
Then register it in your other class to fire your method.
您什么时候调整图像的插图?如果您在 ViewWillAppear (或 ViewDidAppear)中执行此操作,则当模式被关闭时,该方法将被再次调用。
也许你可以在 ViewDidLoad 中进行插入调整?
When are you adjusting the inset for your image? If you are doing it in ViewWillAppear (or ViewDidAppear), that method is being called again when the modal is being dismissed.
Perhaps you can make the inset adjustment in ViewDidLoad instead?