Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7759273
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T13:35:12+00:00 2026-06-01T13:35:12+00:00

I have an Image inside UIScrollView which i can zoom in and out. I

  • 0

I have an Image inside UIScrollView which i can zoom in and out.
I have a button that let the user rotate the Image 90 degrees:

(void)RotateImage {
    CGAffineTransform rotateTrans = CGAffineTransformMakeRotation(-90.0 / 180.0 * 3.14);
    BaseImg.transform = rotateTrans;
}

After the imaged is rotated i cannot zoom in and out.. the image is going crazy on the screen and going back to the UNRotated state.

What am i doing wrong? code examples will be great!
Thanks 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T13:35:14+00:00Added an answer on June 1, 2026 at 1:35 pm

    UIScrollView likes to take over the transforms of the views it contains. There are two solutions:

    1. Rotate the image without changing the containing view.
    2. Create a UIView subclass that displays an image within a sublayer.

    To rotate the image, see How to Rotate a UIImage 90 degrees?. If you’re always and only doing 90 degree rotation, see @Peter Sarnowski’s solution. To adapt it to what you’re doing here, assuming that BaseImg is a UIImageView:

    - (void) rotateImage
    {
        UIImage *sourceImage = [baseImg image];
        UIImage *rotatedImage = [UIImage imageWithCGImage:[sourceImage CGImage] scale:1.0 orientation:UIImageOrientationRight];
        [baseImg setImage:rotatedImage];
    }
    

    This will only rotate once. To have rotateImage work repeatedly, read the existing orientation property and move it on to the next in clockwise or anticlockwise order.

    If the image is not square, you may also need to resize baseImg to reflect its new aspect ratio.

    To create a UIView subclass, you need to have it store a CALayer as a sublayer of the view layer. Store the image in the sublayer, and transform the sublayer at will. This is faster, and allows arbitrary rotation, but you need to calculate your own scaling to prevent the rotate image going outside the view bounds.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an UIImageView inside an UIScrollView. I want that the user can zoom
in my app i have UIImageView inside UIScrollview which i can zoom in and
I have a UIImageView that is housed inside a UIScrollView . The image in
I have a button and image inside it in my silverlight user control. When
I have an image view that is inside of a UIScrollView so that I
I have an image inside an UIImageView which is within a UIScrollView. What I
I have an application that displays an image inside of a Windows Forms PictureBox
I have an UIImageView with an image (map) inside of a UIScrollView. I add
I have an iPhone application that is supposed to show images inside a UIScrollView.
So I have a UIViewController subclass called MyTabBarViewController that has a UIScrollView. Inside of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.