Mangy92
Mangy92

Reputation: 631

How do I make my image zoomable in a scrollview?

I want my image called bildfraga to be zoomable. It is placed in the scrollview called scroll. I am able to scroll the picture, but not zoom it.

This is my code when the image is shown:

  bildfraga = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"dtk2.png"]];
scroll.contentSize = bildfraga.frame.size;
[scroll addSubview:bildfraga];
scroll.minimumZoomScale = 0.4;
scroll.maximumZoomScale = 4.0;
[scroll setZoomScale:scroll.minimumZoomScale];

- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scroll{
return bildfraga;
 } 

But when I try to build this, I get an error saying something like: "Use of undeclared identifier 'viewForZoomingInScrollView'".

Thanks in advance!

/A noob

Upvotes: 0

Views: 245

Answers (1)

Esko918
Esko918

Reputation: 1479

This could be the problem. Did you add UIScrollViewDelegate in your .h file?

Upvotes: 1

Related Questions