ios - imageView 一直被 navigationItem 遮挡

标签 ios objective-c

我找到了一些示例代码。

它通过AppDelegate.m中的代码显示 View

- (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;
}

下图在AITPreviewViewController.xib中。

enter image description here

但是在iPhone上运行View不正常,如下图所示。

最上面的三个imageView一直被navigationItem遮挡

enter image description here

但是当我转向其他 View 时,并使用以下代码返回。

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

    Previewer.edgesForExtendedLayout = UIRectEdgeNone;

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

它显示了如下图所示的普通 View 。

enter image description here

第一次只显示不正常... 这是怎么回事?

是否可以使用Auto-layout来解决这个问题?

最佳答案

如果你不想隐藏导航栏,那么在你的 xib 中做一点改变 Just change the Top Bar property from none to as shown in image

只需将顶部栏属性从无更改为如图所示。它会自动将您的图片放在导航栏下方

关于ios - imageView 一直被 navigationItem 遮挡,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24304567/

相关文章:

Objective-C Clang-Format 方法大括号中断

ios - 在 SSO FBDialog 中使用旧式访问 token ?

ios - 将一个导航栏更改为透明会将所有导航栏更改为透明

ios - NSString decimalValue 方法

objective-c - Objective C Cocoa 从单独的线程更新 gui

ios - 如何在 Cocos2d 中播放音频文件的特定部分

ios - NSArrayController 是否已弃用,它的替代品是什么?

ios - 从Xcode导出苹果开发者账号安全吗

ios - 使用 Storyboard实例化的 Controller 的重新分配

ios - 网络蓝牙在移动设备中的可用程度如何?