ios - UINavigationBar 不会扩展或扩展到设备宽度

标签 ios xcode navigation uinavigationbar extending

导航栏似乎无法适应不同的设备宽度。它只适用于我的 5s,但在模拟器中,它如下所示。

我以前创建过几个应用程序,但从未遇到过这个问题。 关于我在这个项目中做错了什么有什么想法吗?

Notice the background change between the navigation bar and the view background

Similarly, for the iPad Air

最佳答案

我添加了一个类别,以在横向和纵向模式下保持导航栏的高度不变。这是我的错误。删除它,解决了这个问题。

仅供引用,这是类别:

#import "UINavigationBar+DiscoverCustomHeight.h"

@implementation UINavigationBar (DiscoverCustomHeight)
- (CGSize)sizeThatFits:(CGSize)size
{
    CGSize newSize = CGSizeMake(self.frame.size.width,44);
    return newSize;
}
@end

关于ios - UINavigationBar 不会扩展或扩展到设备宽度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31228167/

相关文章:

ios - ios 中的 .dylib 和 .a lib 有什么区别?

ios - 如何显示具有多个导航应用程序选项的操作表

html - 当我尝试悬停时,导航下拉菜单不断消失

html - 带 CSS 的中心导航栏

javascript - Objective C 组件通过字符串分隔

ios - +entityForName : nil is not a legal NSManagedObjectContext parameter searching for entity name 'Account' '

ios - Storyboard:删除派生数据中的文件夹后仍然是 "Unable to write to path"

objective-c - for 循环在editingStyleForRowAtIndexPath 中仅执行一次

iOS 网络浏览器 谷歌搜索

ios - Swift - CGPoint 不可转换为 Character