Gold Challenge Complete


Here’s my solution. It’s pretty self-explanatory. hope this helps!


#import "BNRImageViewController.h"

@interface BNRImageViewController ()<UIScrollViewDelegate>

@property(nonatomic, strong)UIImageView *imageView;


@implementation BNRImageViewController

-(UIView *)viewForZoomingInScrollView:(UIScrollView *)ScrollView{

    return self.imageView;


    UIScrollView *scrollView = [[UIScrollView alloc]init];
    self.imageView =[[UIImageView alloc]initWithImage:self.image];
    self.imageView.contentMode = UIViewContentModeCenter;
    //Center the image in the popover
    [self.imageView setCenter:CGPointMake(600/2,600/2)];
    scrollView.contentSize = self.imageView.frame.size;
    scrollView.scrollEnabled = NO;
    scrollView.minimumZoomScale = 0.5;
    scrollView.maximumZoomScale = 2.0;
    scrollView.delegate = self;
    [scrollView addSubview:self.imageView];
    self.view = scrollView;

//NOTE: Must comment out or delete the two statements below
//in order for it work

    [super viewWillAppear];
    //We must cast the view to UIImageView so the compiler know
    //it is okay to send it setImage:
    //UIImageView *imageView = (UIImageView *)self.view;
   // imageView.image = self.image;



Can you explain why you have to comment out the code in viewDidLoad? I’m a bit confused as to why we even has to cast it in the first place, and why you ended up taking it out.