ios - 从 AppDelegate 加载 Storyboard 在窗口上留下黑色空间

标签 ios iphone storyboard appdelegate

我正在从 AppDelegate 启动 Storyboard,但屏幕顶部和底部出现黑色空间。这是我的代码:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Override point for customization after application launch.

    [[UINavigationBar appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName: [UIColor whiteColor]}];
    [[UINavigationBar appearance] setTintColor:[UIColor whiteColor]];
    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle]];
    UIViewController *vc =[storyboard instantiateInitialViewController];

    // Set root view controller and make windows visible
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    self.window.rootViewController = vc;
    [self.window makeKeyAndVisible];

    return YES;
}  

它是这样的:

enter image description here

最佳答案

这可能是因为您没有 Default-568h@2x.png 启动图像。

尝试添加一个或使用 Assets 目录中的启动图像,并为 iPhone 5 尺寸准备一个。

(也是:self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; 是必要的,它会返回你期望的吗?)

关于ios - 从 AppDelegate 加载 Storyboard 在窗口上留下黑色空间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27677047/

相关文章:

ios - 为什么在我的框架中我可以访问 Storyboard_a.storyboard 而无法访问 Storyboard_b.storyboard?

ios - Xcode 6 - Storyboard UINavigation 后退按钮未出现在应用程序中

ios - 游戏中心 : "The connection to service named com.apple.gamed was interrupted"

iphone - 如何在 MKNetworkKit 或 MKNetworkEngine 中禁用缓存?

iphone - Documents 目录中图像的图像缓存

Ios - 当开关打开/关闭时如何显示/隐藏字段

ios - swift ||从 Superview 动画和删除 subview 时的错误

ios - 如何使视频播放完毕后消失,以便用户可以继续使用该应用程序?

iphone - IOS编译源代码出错?

ios - 在 Interface Builder 中更改方向限制的位置