0

I'm stumped on this one. I'm using an image file that was transferred over and is in the classes public properties. The log file shows me that self.image and newImage are still pointing to the UIImage file. However, no matter how I setup initWithImage the value of self.imageView.image ends up being (null).

Note : imageView is a private class property that is synthesized.

- (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);

Where the self.image comes from from the first view controller:

-(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];
    }];


}

how it's declared synthesized in the next view controller:

in the header file

@property (nonatomic,retain) UIImage *image;

in the .m

@implementation AngleMeasureViewController

@synthesize delegate = _delegate;
@synthesize image = _image;
4

0 回答 0