I have been trying to use the UIScrollView with a UIImageView as its subview so that i cud use the pinch and flick provided by UIScrollView for zooming and panning. but doest seem to work. I have tried by adding the following code. I was a bit unsure about how to make it a UIScrollViewDelegate so i just added as a protocol in @interface line in the .h file added @delegate = self@ line in this code.
CGRect scrollFrame = CGRectMake(20.0, 60.0, 280.0, 280.0); CGRect imageFrame = CGRectMake(20.0, 20.0, 200.0, 200.0); scrollView = [[UIScrollView alloc] initWithFrame:scrollFrame]; scrollView.contentMode = (UIViewContentModeScaleAspectFit); scrollView.autoresizingMask = ( UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight); scrollView.maximumZoomScale = 4; scrollView.minimumZoomScale = 1; scrollView.clipsToBounds = YES; scrollView.delegate = self; slideShowImage = [[UIImageView alloc] initWithFrame:imageFrame]; [scrollView addSubview:slideShowImage]; [[self view] addSubview:scrollView];
Another thing. I found out in the iPhone documentation that we need to implement a couple of methods in a UIScrollViewDelegate. But i didnt understand how to do that. Do i just make empty methods or some logic is to be added there? Basically i didnt really understand the purpose of these two methods. The documentation had the following instructions. bq. The UIScrollView class can have a delegate that must adopt the UIScrollViewDelegate protocol. For zooming and panning to work, the delegate must implement both scrollViewWillBeginZooming: and scrollViewDidEndZooming:withView:atScale:; in addition, the maximum (maximumZoomScale) and minimum ( minimumZoomScale) zoom scale must be different.
Can anyone please explain me what i m doing wrong?