【问题标题】:Objective-C: Status bar hides when I create the window programmaticallyObjective-C:当我以编程方式创建窗口时状态栏隐藏
【发布时间】:2014-10-05 20:06:24
【问题描述】:

我正在尝试在 App 委托中以编程方式创建窗口,但状态栏隐藏了。在 info.plist 中它没有设置为 YES。该应用程序以这种方式完美运行,但我也需要显示状态栏。 我在 AppDelegate.h 中有 window 和 navigationController 属性 这是我的didFinishLaunch

self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
//even when I used customized CGRect and used it initWithFrame, there is no status bar
self.navigationController = [[IEENavigationController alloc] init];
XYZViewController *homeViewController = [[XYZViewController alloc] initWithNibName:@"XYZViewController"  bundle:nil];
[navigationController pushViewController:homeViewController animated:YES];
self.window.rootViewController = self.navigationController;
[window addSubview:navigationController.view];
[self.window makeKeyAndVisible];
return YES;

提前谢谢你

【问题讨论】:

    标签: ios objective-c window statusbar appdelegate


    【解决方案1】:

    你可以在 info.plist 中添加这个:

    UIViewControllerBasedStatusBarAppearance - YES
    

    然后在想要隐藏状态栏的视图控制器中添加这个方法。

    -(BOOL)prefersStatusBarHidden { return YES; }
    

    【讨论】:

    • 在 info.plist 中 UIStatusBarHidden 是否设置为 YES?
    • 不,它是 NO,状态栏最初隐藏也设置为 NO。
    猜你喜欢
    • 2014-06-02
    • 1970-01-01
    • 2013-10-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-07-28
    • 2014-12-29
    • 1970-01-01
    相关资源
    最近更新 更多