Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UIImageView bounds keeps growing as image rotates #33

Open
kevvo1288 opened this issue Aug 27, 2011 · 0 comments
Open

UIImageView bounds keeps growing as image rotates #33

kevvo1288 opened this issue Aug 27, 2011 · 0 comments

Comments

@kevvo1288
Copy link

When you rotate an image, the UIImageView bounds keeps growing. You can use the following logging code to see what i mean. Replace the layoutSubviews Code in KTPhotoViewer.m with the following code:

- (void)layoutSubviews 
{
   [super layoutSubviews];

   if ([self isZoomed] == NO && CGRectEqualToRect([self bounds], [imageView_ frame]) == NO) {

       NSLog(@"\n\nBefore:\n");
       NSLog(@"\nframe: %.0f, %.0f, %.0f, %.0f\n\n", imageView_.frame.origin.x, imageView_.frame.origin.y, imageView_.frame.size.width, imageView_.frame.size.height);
       NSLog(@"\nimage bounds: %.0f, %.0f, %.0f, %.0f\n\n", imageView_.bounds.origin.x, imageView_.bounds.origin.y, imageView_.bounds.size.width, imageView_.bounds.size.height);
       NSLog(@"\nself bounds: %.0f, %.0f, %.0f, %.0f\n\n", [self bounds].origin.x, [self bounds].origin.y, [self bounds].size.width, [self bounds].size.height);

      [imageView_ setFrame:[self bounds]];

       NSLog(@"\n\nAfter:\n");
       NSLog(@"\nframe: %.0f, %.0f, %.0f, %.0f\n\n", imageView_.frame.origin.x, imageView_.frame.origin.y, imageView_.frame.size.width, imageView_.frame.size.height);
       NSLog(@"\nimage bounds: %.0f, %.0f, %.0f, %.0f\n\n", imageView_.bounds.origin.x, imageView_.bounds.origin.y, imageView_.bounds.size.width, imageView_.bounds.size.height);
       NSLog(@"\nself bounds: %.0f, %.0f, %.0f, %.0f\n\n", [self bounds].origin.x, [self bounds].origin.y, [self bounds].size.width, [self bounds].size.height);
   }
}

You should see on every rotation the bounds increasing (length for portrait, height for landscape).

The reason why this is a problem for me is that the app I am working on I wanted to put labels on top of the images with tags. The labels would be added as subviews to the main view. However, things like text gets shrunk everytime the bounds increase, which means on every rotation the labels become more and more unreadable.

I've tried looking around to try and solve the problem but right now its beyond me. Anyone have any ideas/suggestions for a fix?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant