简体   繁体   English

imageView已被navigationItem遮挡

[英]The imageView has been obstructing by navigationItem

I found some sample code. 我找到了一些示例代码。

It show the view by following code in AppDelegate.m 它通过遵循AppDelegate.m代码来显示视图

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    // Override point for customization after application launch.

    UILocalNotification *notification = [launchOptions objectForKey:UIApplicationLaunchOptionsLocalNotificationKey];

    if (notification) {
        NSLog(@"AppDelegate didFinishLaunchingWithOptions");
        application.applicationIconBadgeNumber = 0;
    }

    AITPreviewViewController *previewViewController = [[AITPreviewViewController alloc] initWithNibName:@"AITPreviewViewController" bundle:nil];

    navigationController = [[UINavigationController alloc]initWithRootViewController:previewViewController];

    [self.window setRootViewController:navigationController] ;

    self.window.backgroundColor = [UIColor whiteColor];
    [self.window makeKeyAndVisible];
    return YES;
}

The following picture is in the AITPreviewViewController.xib . 下图是在AITPreviewViewController.xib

在此处输入图片说明

But the View is not normal when it run on the iPhone , it show like the following picture. 但是View在iPhone上运行时不正常,它显示如下图。

The three imageView on the top has been obstructing by navigationItem 顶部的three imageView已被navigationItem遮挡

在此处输入图片说明

But when I turn to other View , and use the following code to turn back. 但是,当我转到其他View时,并使用以下代码返回。

UIViewController *Previewer = [[AITPreviewViewController alloc] initWithNibName:@"AITPreviewViewController" bundle:nil] ;

    Previewer.edgesForExtendedLayout = UIRectEdgeNone;

    [self.navigationController pushViewController:Previewer animated:YES];

It show the normal View like the following picture. 它显示正常的视图,如下图所示。

在此处输入图片说明

The View only show not normal at first time... What happened to this condition ? 视图仅在第一次显示不正常...这种情况发生了什么?

Can it use Auto-layout to solve this problem ? 它可以使用Auto-layout来解决此问题吗?

If you don't want to hide navigation bar then in your xib just make a little change 如果您不想隐藏导航栏,则在您的xib中进行一些更改 只需将Top Bar属性从无更改为如图所示

Just change the Top Bar property from none to as shown in image. 只需将Top Bar属性从无更改为如图所示。 It will auto place your image below the navigation bar 它将自动将您的图像放置在导航栏下方

Try increasing the 'Y' value for those 3 images from your interface builder. 尝试从您的界面构建器中增加这3张图片的“ Y”值。 Select each image and then go to Size Inspector. 选择每个图像,然后转到“大小检查器”。 There you will see some values. 在那里,您将看到一些值。 Find the Y value and increase it. 找到Y值并增加它。 This will push the images down. 这将向下推图像。

如果您只想根据“ AITPreviewViewController.xib”显示UI,则可以隐藏导航栏。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM