出现UIImagepickerController
时如何隐藏“状态栏”?
这里我使用的是iOS编码和xcode 5。
出现相机时,我会隐藏“状态栏”。有代码吗?
答案 0 :(得分:1)
**Try this Code :-**
- (void)viewWillAppear:(BOOL)animated
{
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationNone];
}
- (void)viewWillDisappear:(BOOL)animated
{
[[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationNone];
}
// iOS 7在info.plist文件中设置此属性。
答案 1 :(得分:1)
请尝试这个:
首先在.plist文件中设置。
'View controller-based status bar appearance' and set to NO.
添加您的AppDelegate方法
[application setStatusBarHidden:NO];
[application setStatusBarStyle:UIStatusBarStyleDefault];
如果您想更改statsubar颜色,请根据您的应用背景颜色更改 setStatusBarStyle 。
你也可以尝试:
- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated
{
[[UIApplication sharedApplication] setStatusBarHidden:YES];
}
答案 2 :(得分:0)
转到plist文件并添加新行View Controller-Based Status Bar Appearance
这应该可以解决这个问题。
答案 3 :(得分:0)
将此行放入相机按钮方法
[[UIApplication sharedApplication] setStatusBarHidden:YES animated:NO];
答案 4 :(得分:0)
您添加此代码
- (void)navigationController:(UINavigationController *)navigationController
willShowViewController:(UIViewController *)viewController
animated:(BOOL)animated {
if(IS_IOS_7){
if ([navigationController isKindOfClass:[UIImagePickerController class]] &&
((UIImagePickerController *)navigationController).sourceType == UIImagePickerControllerSourceTypeSavedPhotosAlbum) {
[[UIApplication sharedApplication] setStatusBarHidden:YES];
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
}
}
}