gpt4 book ai didi

ios - UIImagePickerController 在图像选择时关闭父 View

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:26:16 25 4
gpt4 key购买 nike

我的应用程序是基于标签栏的应用程序。我必须提供一个选项,用户可以在个人资料编辑屏幕中更改他的个人资料图片。为此,当用户单击编辑栏按钮时,我从个人资料屏幕推送个人资料编辑屏幕。

UITabBarViewController --> UINavigationController -->ProfileView (UIViewController) --Push--> ProfileEditView(static UITableViewController)

我正在使用下面的代码呈现 UIImagePickerController

 UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
imagePicker.delegate = self;
imagePicker.allowsEditing = YES;
// imagePicker.modalPresentationStyle = UIModalPresentationOverCurrentContext; (when i use this TabBar hiding cancel and chose buttons)
imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[self presentViewController:imagePicker animated:YES completion:nil];

和委托(delegate)方法

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
profileImage = info[UIImagePickerControllerEditedImage];
[_choseProfilePicButton setBackgroundImage:profileImage forState:UIControlStateNormal];

if ([picker isKindOfClass:[UIImagePickerController class]])
{
[picker dismissViewControllerAnimated:YES completion:nil];
}
}

- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
{
[picker dismissViewControllerAnimated:YES completion:nil];
}

当我尝试选择图像并单击选择图像当前 View 返回配置文件屏幕时(配置文件屏幕--推送-->配置文件编辑 View -->呈现 imagePicker Controller -->选择图像-->返回配置文件屏幕)。在选择父 View 后关闭而不是图像选择器 Controller 。需要关闭图像选择器 Controller 并在选择图像后保持在同一屏幕上。请帮助我解决这个问题....

谢谢,

拉基。

最佳答案

我只是处于非常相似的情况,通过将图像选择器的 modalPresentationStyle 设置为“OverCurrentContext”解决了这个问题:

func photoButtonPressed(sender: AnyObject) {
let picker = UIImagePickerController()
picker.delegate = self
picker.sourceType = UIImagePickerControllerSourceType.PhotoLibrary
picker.modalPresentationStyle = UIModalPresentationStyle.OverCurrentContext
presentViewController(picker, animated: true, completion: nil)
}

感谢: ImagePicker dismiss tabBar Nav Controller

关于ios - UIImagePickerController 在图像选择时关闭父 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29740352/

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