Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c UIImagePickerController隐藏取消按钮_Objective C_Xcode_Uinavigationcontroller_Ios8_Uiimagepickercontroller - Fatal编程技术网

Objective c UIImagePickerController隐藏取消按钮

Objective c UIImagePickerController隐藏取消按钮,objective-c,xcode,uinavigationcontroller,ios8,uiimagepickercontroller,Objective C,Xcode,Uinavigationcontroller,Ios8,Uiimagepickercontroller,我有一个UIImagePickerController,它可以通过按下按钮打开。下面是我用来打开UIImagePickerController的代码 - (BOOL)shouldStartPhotoLibraryPickerController { if (([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary] == NO &&a

我有一个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中的一个bug还是我做错了什么?感谢您的帮助

试试这个:
cameraPicker.modalPresentationStyle=UIModalPresentationCurrentContext

谢谢,但我仍然有这个问题。我还发现了一个非常奇怪的现象,如果我按下后退按钮返回,取消按钮就会消失,但如果我从手机的左边缘滑动返回,取消按钮就会保留。我面临的问题也是一样的。你有解决办法吗?我也有同样的问题。您得到答案了吗?如果每个案例都不起作用,请参考此答案stackoverflow.com/a/50490924/1201274