2014-10-05 64 views
-1

我试图在应用程序委托中以编程方式创建窗口,但隐藏了状态栏。在info.plist中它没有被设置为YES。这款应用完全可以工作,但我也需要显示状态栏。在这里AppDelegate.h 我有窗口和navigationController属性是我didFinishLaunchObjective-C:以编程方式创建窗口时隐藏状态栏

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; 

预先感谢您

回答

0

你可以在info.plist中添加此:

UIViewControllerBasedStatusBarAppearance - YES 

再加入这个方法在你想隐藏状态栏的视图控制器中。

-(BOOL)prefersStatusBarHidden { return YES; } 
+0

谢谢lain,但它没有工作 – Hadis 2014-10-05 21:06:03

+0

在info.plist中是否将UIStatusBarHidden设置为YES? – 2014-10-05 21:12:17

+0

不,它是NO,状态栏最初被隐藏设置为NO。 – Hadis 2014-10-05 21:47:14