我很难过这个。我正在使用一个转移过的图像文件,它位于类公共属性中。日志文件显示self.image和newImage仍然指向UIImage文件。但是,无论我如何设置initWithImage,self.imageView.image的值最终都是(null)。
注意:imageView是一个合成的私有类属性。
- (void)viewDidLoad
{
[super viewDidLoad];
self.view.frame = (CGRect){.origin=CGPointMake(0.0f, 0.0f), .size=self.image.size};
UIImage *newImage = self.image;
self.imageView = [[UIImageView alloc] initWithImage:newImage];
[self.imageView setFrame: (CGRect){.origin=CGPointMake(0.0f, 0.0f), .size=self.image.size}];
[self.scrollView addSubview:self.imageView];
self.scrollView.contentSize = self.image.size;
NSLog(@"Image in self.image : %@ Image for imageView %@ and new Image is : %@", self.image, self.imageView.image, newImage);
self.image来自第一个视图控制器:
-(void)imagePickerController:
(UIImagePickerController *)picker
didFinishPickingMediaWithInfo:(NSDictionary *)info
{
NSString *mediaType =
[info objectForKey:UIImagePickerControllerMediaType];
if ([mediaType isEqualToString:(NSString *)kUTTypeImage])
{
self.imageToBePassed = [info objectForKey:UIImagePickerControllerOriginalImage];
[picker dismissViewControllerAnimated:NO completion:^(){
AngleMeasureViewController *angleMeasureViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"AngleMeasureViewController"];
angleMeasureViewController.delegate = (id)self;
angleMeasureViewController.image = self.imageToBePassed;
NSLog(@"image passed to Angle Measure View Controller : %@", angleMeasureViewController.image);
[self.navigationController pushViewController:angleMeasureViewController animated:YES];
}];
}
如何在下一个视图控制器中声明它的合成:
头文件中的
@property (nonatomic,retain) UIImage *image;
<。> <。>
@implementation AngleMeasureViewController
@synthesize delegate = _delegate;
@synthesize image = _image;