0
所以我开始认为这将是非常简单的,但我真的无法弄清楚如何做到这一点!基本上我使用TabBar应用程序,因此每个页面由UITabBarController
管理。我创建了一个UIImage,当您从照片库中选择它时显示,我希望该选择显示在不同的视图控制器中。这是我在第一个VC代码:如何在第二个ViewController中从一个ViewController显示UIImage?
- (void)addNew:(id)sender {
NSLog(@"Clicked");
UIImagePickerController *controller = [[UIImagePickerController alloc] init];
controller.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[self presentModalViewController:controller animated:YES];
[controller setDelegate:self];
[self.photoView.view removeFromSuperview];
}
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage : (UIImage *)image editingInfo:(NSDictionary *)editingInfo {
NSLog(@"this function has started");
[self.view setAlpha:1.0f];
imageV1 = [[UIImageView alloc] initWithImage:image];
imageV1.frame = CGRectMake(10, 200, 100, 100);
image1 = image;
[imageV1 setImage:image];
[scrollView addSubview:imageV1];
[self dismissModalViewControllerAnimated:YES];
}
因此,显示图像在这个视图(这不是我想要的)。我希望它在这个视图中显示:
- (void)viewDidLoad
{
[scrollView setScrollEnabled:YES];
[scrollView setContentSize:CGSizeMake(320, 500)];
imageV2 = [[UIImageView alloc] initWithFrame:CGRectMake(10, 50, 100, 100)];
imageV2.backgroundColor = [UIColor blueColor];
self.imageV2.image = VC1.imageV1.image;
[imageV2 setImage:VC1.image1];
[scrollView addSubview:imageV2];
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
}
我已经通过创建VC1
ViewControllerOne *VC1;
@property (nonatomic, retain) ViewControllerOne *VC1;
我希望我已经很好地解释这个实例连接的两个VC的,而是要总结我想当从ViewController中弹出的光盘库中选择UIImage时,能够在ViewController 2中显示UIImage 1
很酷,我会试试看,并回复给你。感谢你的回复,我总是很难解释这些事情,除非我实际展示某人,但感谢你的建议! – Ollie177