Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/118.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
将0.5点高度子视图添加到iOS7中未显示的UINavigationBar_Ios_Objective C_Ios7_Uiview_Uinavigationbar - Fatal编程技术网

将0.5点高度子视图添加到iOS7中未显示的UINavigationBar

将0.5点高度子视图添加到iOS7中未显示的UINavigationBar,ios,objective-c,ios7,uiview,uinavigationbar,Ios,Objective C,Ios7,Uiview,Uinavigationbar,我有一个类继承自UINavigationBar,我想添加一条分隔线作为其子视图,以分隔导航栏和导航内容 线的高度定义如下 #define SEPERATOR_LINE_HEIGHT (1.0f / [UIScreen mainScreen].scale) 我的代码: @interface MyPopNavigationBar : UINavigationBar @end @implementation MyPopNavigationBar { UIView *separatorLin

我有一个类继承自
UINavigationBar
,我想添加一条分隔线作为其子视图,以分隔导航栏和导航内容

线的高度定义如下

#define SEPERATOR_LINE_HEIGHT (1.0f / [UIScreen mainScreen].scale)
我的代码:

@interface MyPopNavigationBar : UINavigationBar
@end

@implementation MyPopNavigationBar {
    UIView *separatorLine;
}

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.clipsToBounds = YES;
        self.translucent = NO;

        separatorLine = [[UIView alloc] initWithFrame:CGRectMake(0, CGRectGetHeight(self.bounds) - SEPERATOR_LINE_HEIGHT, CGRectGetWidth(self.bounds), SEPERATOR_LINE_HEIGHT)];
        separatorLine.backgroundColor = [UIColor redColor];
        separatorLine.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleTopMargin;
        [self addSubview:separatorLine];
    }
    return self;
}
这在iOS 6和iOS 8(全部为视网膜)中都能正常工作,但在iOS 7(视网膜)中我看不到我的
separatorLine

iOS 6和8:

iOS 7:

此外,当我试图将分隔线高度设置为精确的1时,它会显示在所有iOS版本中

separatorLine = [[UIView alloc] initWithFrame:CGRectMake(0, CGRectGetHeight(self.bounds) - 1, CGRectGetWidth(self.bounds), 1)];


怎么了?

我自己解决了这个问题。这是因为
自动重定尺寸磁盘的故障是一个类似的问题。