Redbar在解雇UIImagePickerController时注意到

时间:2014-10-30 11:06:23

标签: ios uiimagepickercontroller

我正在使用UIImagePickerController来录制,编辑和保存视频到文件。在关闭UIImagePickerController时,状态栏闪烁红色并消失。我想避免这种情况。从iOS8.1,iOS8,iOS7.1等开始降低频率,我一直注意到这一点

- (void) cameraClicked{
    self.recordState=KRERecordStateRecording;
    UIImagePickerController *pickerController = [[UIImagePickerController alloc] init];
    pickerController.delegate  = self;
    pickerController.sourceType = UIImagePickerControllerSourceTypeCamera;

    if(self.mediaType==MediaTypePhoto){
        pickerController.mediaTypes = [[NSArray alloc] initWithObjects: (NSString *) kUTTypeImage, nil];

    }else if(self.mediaType==MediaTypeVideo){
        pickerController.mediaTypes = [[NSArray alloc] initWithObjects: (NSString *) kUTTypeMovie, nil];
        pickerController.allowsEditing = YES;
        pickerController.videoMaximumDuration=30.0f;
    }
    [self presentViewController:pickerController animated:YES completion:nil];
}

- (void)imagePickerController:(UIImagePickerController *)picker
        didFinishPickingImage:(UIImage *)image
                  editingInfo:(NSDictionary *)editingInfo{

}
- (void)imagePickerController:(UIImagePickerController *)picker
didFinishPickingMediaWithInfo:(NSDictionary *)info{

    [picker dismissViewControllerAnimated:YES completion:nil];

    NSString *mediaType = [info objectForKey: UIImagePickerControllerMediaType];
    if (CFStringCompare ((CFStringRef) mediaType, kUTTypeImage, 0)
        == kCFCompareEqualTo) {
        self.selectedMedia = [[NSArray alloc] initWithObjects:[info objectForKey:UIImagePickerControllerOriginalImage], nil];
        [self saveMedia];
    }else if(CFStringCompare ((CFStringRef) mediaType, kUTTypeMovie, 0)
             == kCFCompareEqualTo){
        videoURL= [info objectForKey:UIImagePickerControllerMediaURL];
        [self saveMedia];
    }
}
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker{
    [picker dismissViewControllerAnimated:YES completion:nil];
}

2 个答案:

答案 0 :(得分:6)

替代方法!!

我无法找到问题的实际解决方案,但确实找到了解决方法。 关闭AudioSession

[[AVAudioSession sharedInstance] setActive:NO error:nil] 
在解雇UIImagePickerController之前,

似乎是唯一的选择。 经验证可以满足我的需求。但可能不是一个理想的解决方案

答案 1 :(得分:0)

我也有同样的问题,我发现原因是在.plist中查看"查看基于控制器的状态栏外观"价值是NO。解决了你应该设置的问题"查看基于控制器的状态栏外观"值为YES。祝你好运!!!