Objective c UIImagePickerController隐藏取消按钮
我有一个UIImagePickerController,它可以通过按下按钮打开。下面是我用来打开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
- (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