Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Uiimageview inside uiscrollview position is not centered

I am developing an app for iPhone/iPad using Objective C. In my app I am having an UiScrollView which is having an UIImageView inside it. I can scroll and Zoom the Image inside the Scroll View.

All works fine.But my problem is that when I am loading the Image Inside a uiscrollview, its position is at something at center but not exactly.

I want that either my image should be center aligned or at the Top Left corner.

I had set the contentoffset to (0,0) and also tried setting the AutoresizingMask to different values.

Please let me know if somebody has any idea or solution.

like image 454
Mandeep Kaur Avatar asked Feb 10 '12 10:02

Mandeep Kaur


1 Answers

contentoffset is something of the scrollview and is probably not right for this situation. If you want the image to be in the center do this:

imageview.center = scrollview.center;

If you want the image to be at the top left corner of the scrollview do this:

imageview.frame = CGRectMake(0,0,image_width,image_height);

Good luck!

like image 59
Bob de Graaf Avatar answered Sep 19 '22 22:09

Bob de Graaf