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

时间:2015-07-05 07:39:03

标签: ios xcode navigation uinavigationbar extending

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

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

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

Similarly, for the iPad Air

1 个答案:

答案 0 :(得分:2)

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

仅供参考,这是类别:

#import "UINavigationBar+DiscoverCustomHeight.h"

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