iOS 7状态栏中的UIImagePickerController

时间:2013-09-27 08:22:01

标签: uiimagepickercontroller ios7 uistatusbar

在io7中,视图顶部的状态栏是一场噩梦。很幸运,我设法让它工作,所以它将被放置在视图上方。我这样做了:

- (void)viewDidLoad
{
    [super viewDidLoad];
    if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0) {
         self.view.backgroundColor=[UIColor colorWithRed:(152/255.0) green:(204/255.0) blue:(51/255.0) alpha:1] ;
        CGRect frame = self.topNav.frame; frame.origin.y = 20;
        self.topNav.frame = frame;
    }
....
}

现在我的状态栏位于导航栏上方。

但是当谈到调用UIImagePickerController时,情况就不同了。上面的代码没有效果。 我试着这样做:

- (void)showImagePickerForSourceType:(UIImagePickerControllerSourceType)sourceType
{


    UIImagePickerController *imagePickerController = [[UIImagePickerController alloc] init];

 if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0) {

            CGRect frame = self.imagePickerController.frame; frame.origin.y = 20;
           self.imagePickerController.frame = frame;
        }

    imagePickerController.modalPresentationStyle = UIModalPresentationCurrentContext;
    imagePickerController.sourceType = sourceType;
    imagePickerController.delegate = self;
    self.imagePickerController = imagePickerController;
    self.imagePickerController.allowsEditing=YES;
....
}

结果是:

enter image description here

我的状态栏(显示相机拍照时)是否有可能控制相机?

谢谢。

5 个答案:

答案 0 :(得分:16)

我有同样的问题...并解决我的问题...... 在.plist文件中添加密钥

'View controller-based status bar appearance' and set to NO.

并添加appDelegate。

[application setStatusBarHidden:NO]; 
[application setStatusBarStyle:UIStatusBarStyleDefault]; 

注意: - 根据您的应用背景颜色更改**setStatusBarStyle**

答案 1 :(得分:0)

设置基于视图控制器的状态栏外观'并设置为NO。

并添加appDelegate。

[application setStatusBarHidden:NO]; [application setStatusBarStyle:UIStatusBarStyleDefault];

答案 2 :(得分:0)

试试这个

- (void)navigationController:(UINavigationController *)navigationController     willShowViewController:(UIViewController *)viewController animated:(BOOL)animated
{
    [[UIApplication sharedApplication] setStatusBarHidden:YES];
}

答案 3 :(得分:0)

在App的Info.plist文件中添加:

"View controller-based status bar appearance" == NO

在appdelegae.m文件中,在

中添加以下代码
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

  [application setStatusBarHidden:NO];
  [application setStatusBarStyle:UIStatusBarStyleBlackTranslucent];

}

答案 4 :(得分:-1)

这是iOS 7.0中的一个错误,已在iOS 7.1中修复