iOS 7 - 在 ViewController 之间传递数据(图像)

标签 ios objective-c uiimageview

我有一个 Controller ,我在其中使用 UIImagePicker 拍照,拍摄的照片立即显示在 UIImageView 中。好吧,我想知道的是如何将此图像传递给另一个 viewController。

我知道如何使用 PrepareForSegue 方法在 ViewControlller 之间传递数据,但我不知道如何在上述情况下传递图像。

有什么想法吗?

最佳答案

您可以在目标 View Controller 中定义一个 UIImage 属性,然后在 prepareForSegue 中传递您的图像

你的目标 View Controller :

@interface DestinationController : UIViewController
@property (nonatomic,strong) UIImage * image;
@end

在你的 sourceController 中 prepareForeSegue

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    DestinationController *destination =(DestinationController*)segue.destinationViewController;

    destination.image = your_picked_image;
}

关于iOS 7 - 在 ViewController 之间传递数据(图像),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22327792/

相关文章:

ios - 如何在 Xcode 的 IB 中正确约束这些 UIImageView?

ios - 当 iPad 旋转到横向时调整 UIImageView 的尺寸

ios - Flutter 为 BlinkId 插件添加新的 ViewController

ios - 如何在不更改 iOS 中的图像的情况下删除 imageview 上的绘图?

iphone - 使用谷歌地图中的参数开始逐向行驶

objective-c - ReplaceObjectAtIndex 似乎不起作用

c++ - 正确地将 B 转换为 MB,或者完全错误

ios - 实现 UIImage 问题的预期解决方案

ios - 每 5 秒递增 NSnumber - Cocos2d

ios - 如果应用程序被终止,取消计划的 UILocalNotification