adding UIImageView to UIScrollView throws exception cocoa touch for iPad

Posted by Brodie4598 on Stack Overflow See other posts from Stack Overflow or by Brodie4598
Published on 2010-03-28T02:38:27Z Indexed on 2010/03/28 2:43 UTC
Read the original article Hit count: 1193

I am a noob at OBJ-C :)

I am trying to add a UIImageView to a UIScrollView to display a large image in my iPad app.

I have followed the tutorial here exactly:

http://howtomakeiphoneapps.com/2009/12/how-to-use-uiscrollview-in-your-iphone-app/

The only difference is that in my App the View is in a seperate tab and I am using a different image.

here is my code:

- (void)viewDidLoad {
    [super viewDidLoad];
    UIImageView *tempImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Cheyenne81"]];
    self.imageView = tempImageView;
    [tempImageView release];

    scrollView.contentSize = CGSizeMake(imageView.frame.size.width, imageView.frame.size.height);
    scrollView.maximumZoomScale = 4.0;
    scrollView.minimumZoomScale = 0.75;
    scrollView.clipsToBounds = YES;
    scrollView.delegate = self;
    [scrollView addSubview:imageView];
}

- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView{
    return imageView;
}

and:

@interface UseScrollViewViewController : UIViewController<UIScrollViewDelegate>{
    IBOutlet UIScrollView *scrollView;
    UIImageView *imageView;
}

@property (nonatomic, retain) UIScrollView *scrollView;
@property (nonatomic, retain) UIImageView *imageView;

@end

I then create a UIScrollView in Interface Builder and link it to the scrollView outlet. Thats when I get the problem. When I run the program it crashes instantly. If I run it without linking the scrollView to the outlet, it will run (allbeit with a blnk screen).

The following is the error I get in the console: 2010-03-27 20:18:13.467 UseScrollViewViewController[7421:207] * Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key scrollView.'

© Stack Overflow or respective owner

Related posts about cocoa-touch

Related posts about objective-c