UIImagePickerController隐藏了取消按钮

时间:2014-10-13 15:55:33

标签: objective-c xcode uinavigationcontroller ios8 uiimagepickercontroller

我有一个UIImagePickerController,可以通过按下按钮打开。这是我用来打开UIImagePickerController的代码

- (BOOL)shouldStartPhotoLibraryPickerController {
    if (([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary] == NO
         && [UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeSavedPhotosAlbum] == NO)) {
        return NO;
    }

    UIImagePickerController *cameraUI = [[UIImagePickerController alloc] init];
    [cameraUI.navigationBar setBarTintColor:[UIColor colorWithRed:17/255 green:19/255 blue:18/255 alpha:1]];
    if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary]
        && [[UIImagePickerController availableMediaTypesForSourceType:UIImagePickerControllerSourceTypePhotoLibrary] containsObject:(NSString *)kUTTypeImage]) {

        cameraUI.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
        cameraUI.mediaTypes = [NSArray arrayWithObject:(NSString *) kUTTypeImage];

    } else if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeSavedPhotosAlbum]
               && [[UIImagePickerController availableMediaTypesForSourceType:UIImagePickerControllerSourceTypeSavedPhotosAlbum] containsObject:(NSString *)kUTTypeImage]) {

        cameraUI.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;
        cameraUI.mediaTypes = [NSArray arrayWithObject:(NSString *) kUTTypeImage];

    } else {
        return NO;
    }

    cameraUI.allowsEditing = YES;
    cameraUI.delegate = self;

    [Flurry logEvent:@"Picture Choosen"];
    [self presentViewController:cameraUI animated:YES completion:nil];

    return YES;
}

视图第一次正常打开。没有状态栏和预期的取消按钮。但是一旦选择了任何相册,状态栏就会显示,当我导航回相册列表视图时,状态栏会保持不变,取消按钮就不再存在了。这只发生在iOS 8中。我在iOS 7上没有任何问题。我也在iOS 8.1上进行了测试,但仍然存在问题。这是iOS中的错误还是我在这里做错了什么?任何帮助表示赞赏。

enter image description here

enter image description here

1 个答案:

答案 0 :(得分:1)

试试这个: cameraPicker.modalPresentationStyle = UIModalPresentationCurrentContext