iphone - 将图像从一个 View 设置为另一个 xcode 4.4

标签 iphone objective-c ios xcode uiimageview

我有 2 个 View ,它们是 UITabBarController 的一部分。我为每个 View 声明了一个不同的类。

PictureViewController 方法:

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo
{
    [imagePicker dismissModalViewControllerAnimated:YES];
    [imageField setImage:image];
}

另一个 View :AdjustViewController 和另一个 UIImage:

@property (weak, nonatomic) IBOutlet UIImageView *viewImage;

我想在上面的方法 - didFinishPickingImage 中将 AdjustViewController 中的 viewImage 的值设置为所选图像。

我该怎么做?

最佳答案

由于这两个都在 tabBarController 中,您可以使用 tabBarController 获取对另一个 View Controller 的引用并从那里访问其属性。

像这样:

NSArray *theViewControllers = [self.tabBarController viewControllers];

//On this line, you will need to use the Index of the AdjustViewController (0 is on the left and then they go in order from left to right.)
AdjustViewController *adjViewController = (AdjustViewController *)[theViewControllers objectAtIndex:0];

adjViewController.viewImage.image = image;

这会将图像分配给 UITabBarControllerAdjustViewControllerviewImage 属性,假设您使用了正确的索引。

或者,如果您想将内容压缩到尽可能少的行中:

((AdjustViewController *)[[self.tabBarController viewControllers] objectAtIndex:0]).viewImage.image = image;

关于iphone - 将图像从一个 View 设置为另一个 xcode 4.4,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12184486/

相关文章:

iPhone - 动态改变颜色

objective-c - 为什么 UIView.exclusiveTouch 不起作用?

ios - 在 Ios 中排序时间范围

ios - 导航栏不出现

ios - 使用 raix :push 发送推送通知时没有任何反应

ios - 在 ios 的 uitableview 中自定义单元格编辑样式

iphone - 每部 iPhone/iPod Touch 是否都有唯一的 ID?

iphone - 显示带有视频和链接的 PDF

ios - SBStatusBarController 实例

iphone - 为什么在 Objective-C 上保留属性可能不保留?