【发布时间】:2015-03-11 11:22:05
【问题描述】:
我有一个 ViewController,它拥有一个自定义 UIView 作为它的成员,如下所示:@property (nonatomic, strong) IBOutlet ProfileUIView * profileUIView;
在我的 ViewController 中,我从 imagePickerController:didFinishPickingMediaWithInfo: 那里得到一个 UIImage '我将 UIImage 分配给我的 ProfileUIView 中的本地 UIImage 变量。我看到 UIImage 变量被分配,但是,在 set 函数结束后 UIImage 变量得到 nil 并且我以某种方式丢失了图像。
这是 imagePickerController:didFinishPickingMediaWithInfo: 的 sn-p: 在我的 ViewController 中:
NSString *mediaType = info[UIImagePickerControllerMediaType];
[self dismissViewControllerAnimated:NO completion:nil];
if ([mediaType isEqualToString:(NSString *) kUTTypeImage]) {
[self.profileUIView setPicture:info[UIImagePickerControllerOriginalImage]];
if (_newMedia)
UIImageWriteToSavedPhotosAlbum(self.profileImage, self, @selector(image:finishedSavingWithError:contextInfo:), nil);
}
这里是 setPicture:(UIImage *)image: 在我的 UIView 中的实现:
self.profilePic = image;
[self.pictureButton setBackgroundImage:image forState:UIControlStateNormal];
我该如何解决?
谢谢!
【问题讨论】:
标签: ios objective-c uiimage assign