Redbar Noticed when dismissing UIImagePickerController

风格不统一 提交于 2019-11-29 22:22:26

问题


I am using the UIImagePickerController to record, edit and save Video to file. While dismissing the UIImagePickerController the status bar blinks red and disappears. I want to avoid this. I have been noticing this in decreasing frequency from iOS8.1, iOS8, iOS7.1 ,etc

- (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];
}

回答1:


WORKAROUND!!

I couldn't get an actual solution for the problem but did find a work around. Switch off the AudioSession

[[AVAudioSession sharedInstance] setActive:NO error:nil] 

before dismissing the UIImagePickerController seems to be the only option. This verified to work for my needs. But may not be an ideal solution




回答2:


I also had have the same problem, and I found the reason is in .plist the "View controller-based status bar appearance" value is NO. Solved the problem you should set "View controller-based status bar appearance" value to YES. Good luck!!!



来源:https://stackoverflow.com/questions/26651355/redbar-noticed-when-dismissing-uiimagepickercontroller

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!