How can I insert an image in a scroll view, so that I can zoom it. I am new to objective c. Any help will be greatly appreciated!
A:
Look into ImageKit. In particular, IKImageView. Theoretically, you can put that into your scrollview. I've been playing with this recently...
Granted, I only work in OSX, not iPhone, so your experiences may vary... I'm not sure that IKImageView exists for iPhone, but ImageKit seems to...
Brian Postow
2010-04-09 22:07:46
+1
A:
you have to add following delegate method of scrollview in your *.m file.
- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView{
}
Ok. Let me explain in deep.
- open your yourViewCtr.h file.
- Place following two statements in yourViewCtr.h ( here yourViewCtr is assumed your view controller )
IBOutlet UIScrollView *scrForImg;
IBOutlet UIImageView *imgForScr;
- Save yourViewCtr.h file & open yourViewCtr.xib file.
- Drag & drop UIScrollView in your view controller's view from Interface builder library
- Now, drag & drop UIImageView in that scroll view from Interface Builder library
- Now, Connect both of them to files owner of xib.
- Don't forget to connect the scrollview's delegate to files owner
- Now, Set Max zoom to 5 ( according to your need )
- Save yourViewCtr.xib
-(UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView{
return imgForScr;
}
Hope, It works for you dear. Add comment if any doubts.
sugar
2010-04-10 05:57:14
Thank you very much for your step by step answering. I used the above code. Everything worked fine, but the image is not zooming. How can I zoom it.
iSharreth
2010-04-10 18:14:03
sugar
2010-04-12 06:28:51