gpt4 book ai didi

ios - 如何在另一个 View 中打开图像?

转载 作者:行者123 更新时间:2023-11-29 04:10:15 26 4
gpt4 key购买 nike

我正在尝试制作一个具有 2 个 View 的 iOS 应用程序。第一个 View 包含两个按钮:相机和库。当我选择“库”时,我访问相机胶卷。我想选择一张照片并在另一个 View 中打开它。到目前为止我写了这个函数

-(IBAction) getPhoto:(id) sender {
UIImagePickerController * picker = [[UIImagePickerController alloc] init];
picker.delegate = self;

if((UIButton *) sender == choosePhotoBtn) {
picker.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;
} else {
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
}

[self presentViewController:picker animated:YES completion:nil];

}


- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
[picker dismissViewControllerAnimated:YES completion: Nil];
imageView.image = [info objectForKey:@"UIImagePickerControllerOriginalImage"];
}

在同一 View 中打开我的图像。如何在其他 View 中打开此图像?

最佳答案

你可以做类似的事情

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
UIImage *image = [info objectForKey:@"UIImagePickerControllerOriginalImage"];
[picker dismissViewControllerAnimated:YES completion:^{
YourSeconViewController *svc = [[UIViewController alloc] initWithNibName:@"YourSeconViewController" bundle:nil];
svc.imageView.Image = image;
[self presentViewController:svc animated:YES completion:nil];
}];
}

关于ios - 如何在另一个 View 中打开图像?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14524058/

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