在ios7之前,在AppDelegate里用这行代码就可以隐藏状态栏:
[[UIApplication sharedApplication] setStatusBarHidden:YES];
<key>UIViewControllerBasedStatusBarAppearance</key> <false/>
View controller-based status bar appearance,设置为NO,效果是一样的
配置了这个选项之后,上面那行代码就可以隐藏status bar了
但是,如果应用里用到了UIImagePickerController,在弹出照片选择界面的时候,状态栏又会跑出来,解决的办法是:
先声明Controller实现UINavigationControllerDelegate协议,然后设置为ImagePickerController的delegate
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init]; imagePicker.delegate = self;
- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated { [[UIApplication sharedApplication] setStatusBarHidden:YES]; }
原文:http://blog.csdn.net/kyfxbl/article/details/18737897