gpt4 book ai didi

ios - 我的 UINavigationitem 的 TitleView 在 ios 6 中得到扩展

转载 作者:可可西里 更新时间:2023-11-01 05:37:19 27 4
gpt4 key购买 nike

在我的应用程序中,我在 uinavigation 项目上应用了图像。它在 iOS 5 中运行良好,但在 iOS 6 中得到扩展。我在导航栏中没有左右栏按钮项。我搜索了太多但找不到答案。

这是我的代码:

UIImageView *navigationImage=[[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 98, 34)];
navigationImage.image=[UIImage imageNamed:@"topNav-logo.png"];
self.navigationItem.titleView=navigationImage;

图像显示如下:

screenshot

它应该显示为下图,但在 iOS 6 中显示为扩展,在 iOS 5 中效果很好。

结果是:

result screenshot

最佳答案

我从 iOS 6 开始遇到同样的问题,并找到了最疯狂的解决方法:

再创建一个相同尺寸的 UIImageView。然后将 navigationImage 作为 subview 添加到其中。在我的例子中,这将阻止自动调整大小。

UIImageView *workaroundImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 98, 34)];
[workaroundImageView addSubview:navigationImage];
self.navigationItem.titleView=workaroundImageView;

如果有人找到合适的解决方案或解释,请发布。

关于ios - 我的 UINavigationitem 的 TitleView 在 ios 6 中得到扩展,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13988642/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com