0

注意:在旧屏幕尺寸上一切正常,但在新的 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];

为“ RootViewControllernavigationController”和其他一些视图设置框架,然后将它们添加到其视图中。

    //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 个单元格。

在此处输入图像描述

4

3 回答 3

1

如果您发现自己设置了导航控制器/导航栏的框架,那么您做错了。

大多数时候,您甚至不需要设置视图控制器视图的框架。

您的应用程序委托不需要比这更复杂:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    [self setWindow:[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]];

    [[self window] setRootViewController:[[UINavigationController alloc] initWithRootViewController:[[RootViewController alloc] init]];

    [self.window makeKeyAndVisible];

    return YES;
}
于 2013-05-01T15:10:27.440 回答
0

我最终创建了单独的xib文件

_iPhone_视网膜

在文件名的末尾

这也要求这样的陈述

if (IS_IPHONE_RETINA) {
                View = [[View alloc] initWithNibName:@"View_iPhone_Retina" bundle:[NSBundle mainBundle]];
            }else{
                View = [[View alloc] initWithNibName:@"View" bundle:[NSBundle mainBundle]];
            }

IS_IPHONE_RETINA在 projectname.pch 文件中定义为

#define IS_IPHONE_RETINA ([[UIScreen mainScreen] bounds].size.height == 568 )
于 2013-05-08T13:46:47.007 回答
0

它很可能是您的 RootViewController 笔尖中的设置。对于左侧“对象”列表中的第一个视图,您可能已经设置了 Top Bar 属性。

于 2013-05-01T08:33:15.990 回答