I am a noob at OBJ-C :)
I am trying to add a UIImageView to a UIScrollView to display a large image in my iPhone 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: '[<UIViewController 0x4a179b0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key scrollView.'