在我的应用中,frame
的{{1}}通常用于查找其子视图。但问题是self.view
在iOS6和iOS7之间不一致。在storybaord中禁用了导航栏的半透明选项。使用4英寸视网膜iPhone模拟器在Xcode5中进行测试。
如何让iOS6和iOS7中的self.view.frame
相同?任何帮助将不胜感激。
self.view.frame
登录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);
}
登录iOS6:
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>>