【问题标题】:iOS 8: status bar doesn't work with UIImagePickerControlleriOS 8:状态栏不适用于 UIImagePickerController
【发布时间】:2015-02-08 09:34:53
【问题描述】:

我有一个 UIImagePickerController 的视图..

在我的整个应用程序中:

/* white color */
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];

但在这种情况下我需要查看黑色状态栏,所以我设置它:

/* black color */ 
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault];

我已经在委托中这样做了

- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated;

但似乎无视指令。

仅适用于 iOS this question 和其他内容,但我无法使其工作。

【问题讨论】:

    标签: ios objective-c iphone xcode


    【解决方案1】:

    如果您想更改特定视图方式,只需从您的 xib / storyboad 更改它即可。

    【讨论】:

      【解决方案2】:

      在呈现 UIImagePickerViewController 时尝试这样:

      [self presentViewController:imagePickerController animated:YES completion:^{
          [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault];
      }];
      

      【讨论】:

        【解决方案3】:

        我通过这种方式解决了我的问题:

        UIImagePickerController *imagePickerController = [[UIImagePickerController alloc] init];
        
        if(IS_IOS8_AND_UP) {
            imagePickerController.modalPresentationStyle = UIModalPresentationFullScreen;
        } else {
            imagePickerController.modalPresentationStyle = UIModalPresentationCurrentContext;
        }
        
        imagePickerController.delegate = self;
        [self presentViewController:imagePickerController animated:YES completion:nil];
        

        然后在委托中设置默认状态栏样式。

        希望对您有所帮助!

        【讨论】:

          猜你喜欢
          • 2015-04-21
          • 1970-01-01
          • 1970-01-01
          • 2014-09-12
          • 2018-11-27
          • 2015-07-11
          • 2019-11-13
          • 2014-11-13
          • 2011-04-02
          相关资源
          最近更新 更多