Inconsistent Frame / Bounds of UIImage and UIScrollView

Posted by iFloh on Stack Overflow See other posts from Stack Overflow or by iFloh
Published on 2010-05-21T11:46:07Z Indexed on 2010/05/21 11:50 UTC
Read the original article Hit count: 280

Filed under:
|
|

this one puzzles me. I have an Image with a width of 1600 pixels and height of 1819 pixels.

I load the image as UIImageView into an UIScrollView and set the "contentsize parameter"

iKarteScrollView.contentSize = CGSizeMake(iKarteImageView.bounds.size.width, iKarteImageView.bounds.size.height);
NSLog(@"Frame - width %.6f, height %.6f - Bounds - width %.6f, height %.6f", 
      myImageView.frame.size.width, 
      myView.frame.size.height, 
      myImageView.bounds.size.width, 
      myImageView.bounds.size.height);
NSLog(@"Content size width %.6f, height %.6f", 
      myScrollView.contentSize.width, 
      myScrollView.contentSize.height);

The NSLog shows the following:

Frame - width 1600.000000, height 1819.000000 - Bounds - width 1600.000000, height 1819.000000
Content size width 1600.000000, height 1819.000000

Now comes the miracle, in a subsequent method of the same object I call the same NSLog again. But this time the result is

Frame - width 405.000000, height 411.000000 - Bounds - width 1601.510864, height 1625.236938
Content size width 404.617920, height 460.000000

Why is the frame size suddely 405 by 411 pixels? How can the Bounds be 1601 by 1625 where 1625 is roughly 200 pixels less than the original size?

When Positioning a further UIImageView at the coordinates of 20 by 1625, the UIImageView is displayed an estimated 200 pixels above the bottom of the content of the UIScrollView.

I'm lost ...

© Stack Overflow or respective owner

Related posts about objective-c

Related posts about xcode