gpt4 book ai didi

ios - 关闭 UIImagePickerController

转载 作者:可可西里 更新时间:2023-11-01 06:17:52 27 4
gpt4 key购买 nike

我已经尝试了各种关闭 UIImagePickerController 的方法,但都没有成功。我做错了什么。

- (IBAction)choosePhoto
{
self.picker = [[UIImagePickerController alloc] init];
self.picker.delegate = self;
self.picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[self presentModalViewController:self.picker animated:YES];

}

- (void)imagePickerControllerDidCancel:(UIImagePickerController *)imagePicker
{
NSLog(@"dismiss image picker");
[self dismissModalViewControllerAnimated:NO];
[[self.picker parentViewController] dismissModalViewControllerAnimated:NO];
[self.presentedViewController dismissModalViewControllerAnimated:NO];
[self.presentingViewController dismissModalViewControllerAnimated:NO];
// And every other way i could think of
}

- (void)imagePickerController:(UIImagePickerController *)imagePicker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
.. same stuff here
}

我已经尝试从父级、祖父级、navigationController 和根 Controller 中呈现选择器,但没有任何效果。无论我做什么,我都无法关闭 ImagePickerController。

请注意每次都会调用日志语句。

干杯

最佳答案

试试这条线。它可能对您有用。

[self.picker dismissModalViewControllerAnimated:NO];

对于 iOS 6 及更高版本使用此

[self.picker dismissViewControllerAnimated:NO completion:nil];

也可以使用此代码来呈现您的选择器 Controller

if ([self respondsToSelector:@selector(presentViewController:animated:completion:)]){
[self presentViewController:self.picker animated:YES completion:nil];
} else {
//To target iOS 5.0
[self presentModalViewController:self.picker animated:YES];
}

关于ios - 关闭 UIImagePickerController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16475506/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com