2

在我的应用程序中,frameofself.view通常用于定位它的子视图。但问题是self.view.frameiOS6和iOS7之间不一致。导航栏的半透明选项在故事板中被禁用。使用 4 英寸视网膜 iPhone 模拟器在 Xcode5 中进行测试。

我们如何才能self.view.frame在 iOS6 和 iOS7 中做到相同?任何帮助将不胜感激。

- (void)viewDidLoad
{
    [super viewDidLoad];
    if ([self respondsToSelector:@selector(edgesForExtendedLayout)])
    {
        self.edgesForExtendedLayout = UIRectEdgeNone;
    }
    NSLog(@"self.view in viewDidLoad:%@",self.view);
}

-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    NSLog(@"self.view in viewWillAppear:%@",self.view);
}

-(void)viewDidAppear:(BOOL)animated{
    [super viewDidAppear:animated];
    NSLog(@"self.view in viewDidAppear: %@",self.view);
}

登录iOS7:

2013-09-30 14:01:31.584 TestViewFrame[10088:a0b] self.view in viewDidLoad:<UIView: 0xa127b10; frame = (0 0; 320 568); autoresize = RM+BM; layer = <CALayer: 0xa127bb0>>
2013-09-30 14:01:31.587 TestViewFrame[10088:a0b] self.view in viewWillAppear:<UIView: 0xa127b10; frame = (0 64; 320 504); autoresize = RM+BM; layer = <CALayer: 0xa127bb0>>
2013-09-30 14:01:31.591 TestViewFrame[10088:a0b] self.view in viewDidAppear: <UIView: 0xa127b10; frame = (0 64; 320 504); autoresize = RM+BM; layer = <CALayer: 0xa127bb0>>

登录iOS6:

2013-09-30 14:12:32.505 TestViewFrame[10167:c07] self.view in viewDidLoad:<UIView: 0x8158390; frame = (0 20; 320 548); autoresize = RM+BM; layer = <CALayer: 0x81589a0>>
2013-09-30 14:12:32.508 TestViewFrame[10167:c07] self.view in viewWillAppear:<UIView: 0x8158390; frame = (0 0; 320 504); autoresize = RM+BM; layer = <CALayer: 0x81589a0>>
2013-09-30 14:12:32.521 TestViewFrame[10167:c07] self.view in viewDidAppear: <UIView: 0x8158390; frame = (0 0; 320 504); autoresize = RM+BM; layer = <CALayer: 0x81589a0>>
4

0 回答 0