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 8623375
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T07:15:56+00:00 2026-06-12T07:15:56+00:00

There is simple iPad application. Views hierarchy is: Window – UIView – UIImageView UIImageView

  • 0

There is simple iPad application. Views hierarchy is:
Window – UIView – UIImageView
UIImageView has loaded image which is bigger then screen size (i.e. 1280 x 2000 against 768 x 1004). I need to zoom in arbitrary rectangular part of image (fit it on the screen) and then center it on the screen. At the moment I do zooming in following way:

-(IBAction)posIt:(id)sender
{
    // rectangle size and origin in image's coordinates. Its received from out of application
    CGFloat x = 550.f;
    CGFloat y = 1006.f;
    CGFloat w = 719.f;
    CGFloat h = 850.f;

    CGSize frameSize = CGSizeMake(_imgView.image.size.width, _imgView.image.size.height);
    _imgView.frame = CGRectMakeWithParts(CGPointMake(0, 0), frameSize);

    // Calculate center manually because orientation changing
    CGPoint superCenter = CGPointMake(self.view.bounds.size.width/2, self.view.bounds.size.height/2);

    // delta is the factor between size of image size and device screen
    CGFloat delta = 768.f/w;

    // resizing UIImageView to fit rectangle on the screen
    frameSize = CGSizeMake(_imgView.image.size.width * delta, _imgView.image.size.height * delta);
    _imgView.frame = CGRectMakeWithParts(CGPointMake(0, 0), frameSize);

    // Here is I'm trying to calculate center of rectangle
    _imgView.center = CGPointMake(superCenter.x + (superCenter.x - (w/2)*delta - x * delta), superCenter.y + (superCenter.y - (h/2)*delta - y * delta));
}

UIImageView’s ContentMode parameter is AspectFit. I believe that to move one point (UIImageView’s center) to another one (in order to move rectangle to the center of the superView) I shall use following formula:

newX = oldX + oldX – rectCenterX;

newY = oldY + oldY – rectCenterY;

Since UIImageView is scaled with delta factor, rectCenterX and rectCenterY should be multiplied with same delta. But I’m wrong. Rectangles centers jump out from superView center.

Is there exists some way to make these calculations correctly? What do I miss?

Thanks in advance.

  • 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-12T07:15:57+00:00Added an answer on June 12, 2026 at 7:15 am

    I’ve managed correct and stable image centering. Instead of calculating center of image I’m calculating UIImageView’s frame’s origin coordinates like this:

    CGPoint newOrigin = CGPointMake((-zoomRect.origin.x * delta) + superCenter.x - (zoomRect.size.width / 2) * delta, 
                                    (-zoomRect.origin.y * delta) + superCenter.y - (zoomRect.size.height / 2) * delta);
    

    It turns out there is some difference between calculating center and origin. Anyway problem is solved. Thanks everybody.

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

Sidebar

Related Questions

I have an iPad application which has many categorized images I need to switch
I have an ipad application that has a simple core data model with two
There is simple JSON serialization module with name simplejson which easily serializes Python objects
Is there any reference about writing an application on iPad/iPhone to show HTML5 content
As i am new in iPad application development please help me in simple problem.
I am using iSGL3D for an application for the iPad. It's quiete simple. I
How can I create an iPad application that has a navigation bar containing three
I have followed this tutorial http://blogs.wrox.com/article/creating-a-simple-ipad-application-table-view/ (creating a uitableview and populating it). I want
I have created a simple iPad application based on the UISplitViewController template. I'd like
I am developing an iPad application where in there is a requirement that application

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.