To support zooming a image in a UIScrollView, I thought I have to conform the MyController to the UIScrollViewDelegate like as follows. But it works fine without conforming to the UIScrollViewDelegate, even though compiler generates a following warning message.
warning: class 'MyController' does not implement the 'UIScrollViewDelegate' protocol
Isn't it mandatory to conform to the UIScrollViewDelegate in a header file?
Are there any side-effects if I forget to conform?
//@interface MyController : UIViewController <UIScrollViewDelegate>
@interface MyController : UIViewController
{
UIScrollView *scrollView;
UIImageView *imageView;
}
@end
@implementation HelloController
- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView
{
return imageView;
}
- (void)loadView
{
UIImage *img = [UIImage imageNamed:@"foo.png"];
imageView = [[UIImageView alloc] initWithImage:img];
imageView.userInteractionEnabled = NO;
scrollView = [[UIScrollView alloc] initWithFrame: [[UIScreen mainScreen] applicationFrame]];
[scrollView setScrollEnabled:YES];
[scrollView setContentSize:[imageView size]];
[scrollView setMaximumZoomScale:2.0f];
[scrollView setMinimumZoomScale:0.5f];
[scrollView setDelegate:self];
[scrollView addSubview:imageView];
self.view = scrollView;
[scrollView release];
}
@end