注意:在旧屏幕尺寸上一切正常,但在新的 iphone 屏幕 (640x1136) 上一切都差得很远
这是 App Delegate 的初始化和显示myRootViewController
myRootViewController = [[RootViewController alloc] initWithNibName:@"RootViewController" bundle:[NSBundle mainBundle]];
[myRootViewController.view setFrame:[[UIScreen mainScreen] applicationFrame]];
//NSLog(@"rootviewcontroller1 frame %@", NSStringFromCGRect(myRootViewController.view.frame));
//OUTPUTS: {{0, 0}, {320, 460}}
[window addSubview:myRootViewController.view];
为“ RootViewController
navigationController”和其他一些视图设置框架,然后将它们添加到其视图中。
//NSLog(@"ogtest rootviewcontroller frame2 %@", NSStringFromCGRect(self.view.frame));
//OUTPUTS: {{0, 20}, {320, 548}}
[navigationController.view setFrame:CGRectMake(0, 0, 320,528)];
//I have tried multiples variations including not setting it.
loadingView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];
[loadingView setBackgroundColor:[UIColor clearColor]];
UILabel *_loadingLable = [[UILabel alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 80.0f, 20.0f)];
_loadingLable.backgroundColor = [UIColor clearColor];
_loadingLable.textColor = [UIColor whiteColor];
_loadingLable.text = @"Loading...";
[_loadingLable setCenter:CGPointMake(181.0f, 240.0f)];
activityIndicatior = [[UIActivityIndicatorView alloc]initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
[activityIndicatior setCenter:CGPointMake(120.0f, 240.0f)];
RoundedView *_roundedRectangle = [[RoundedView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 140.0f, 50.0f) roundedCorner:RoundedCornersTypeALL];
_roundedRectangle.center = CGPointMake(160.0, 240.0);
_roundedRectangle.rectColor = [UIColor blackColor];
_roundedRectangle.alpha = 0.7;
[loadingView addSubview:_roundedRectangle];
[loadingView addSubview:activityIndicatior];
[loadingView addSubview:_loadingLable];
[_loadingLable release];
[_roundedRectangle release];
[loadingView setHidden:YES];
[self.view addSubview:[navigationController view]];
[self.view addSubview: loadingView];
您可以从下图中看到导航栏的灰色条。带有箭头按钮的文本“Tuesday 30 Apr....”应占据该灰色区域,而不是顶部的 2 个单元格。