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

  • SEARCH
  • Home
  • 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 6985469
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T18:41:04+00:00 2026-05-27T18:41:04+00:00

I am making application for iPad, only landscape mode will be supported. I am

  • 0

I am making application for iPad, only landscape mode will be supported. I am having a UIView and later I am dynamically adding UIImageView as a subview. However my goal is to add images in centre of the UIView. So I used this code,

[imageView setCenter:dynamicMainView.center];

where imageView is UIImageView(Obvious :)) and dynamicMainView is UIView, However final outcome docent seem to be in centre,

Visual Representation

enter image description here


Full method code for adding UIImageView in UIView is,

-(void) addImageIntoMainDynamicView:(UIImage *) image
{
    [self clearImageFromMainDynamicView];//Always clear Dynamic main view before adding new views
    imageView = [[UIImageView alloc] initWithImage:image];  
        if(imageView.bounds.size.width > dynamicMainView.bounds.size.width || imageView.bounds.size.height > dynamicMainView.bounds.size.height)
        {
            [imageView setFrame:[dynamicMainView bounds]];
        }

        [imageView setCenter:dynamicMainView.center];
        NSLog(@"Image : X = %f and Y = %f", imageView.center.x,imageView.center.y );
        NSLog(@"UIView : X = %f and Y = %f", dynamicMainView.center.x,dynamicMainView.center.y );
        [dynamicMainView addSubview:imageView];
    [imageView release];
}

And above log value is,

2011-12-21 21:07:11.850 Map1TestApp[94645:11603] Image : X = 512.000000 and Y = 371.500000
2011-12-21 21:07:11.853 Map1TestApp[94645:11603] UIView : X = 512.000000 and Y = 371.500000

Any clue about why it’s not adding in centre? Am I doing something wrong?


FOR FUTURE VIEWER THE ANWSER WAS :

[imageView setCenter:CGPointMake(CGRectGetMidX([dynamicMainView bounds]), CGRectGetMidY([dynamicMainView bounds]))];
  • 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-05-27T18:41:05+00:00Added an answer on May 27, 2026 at 6:41 pm

    The center of a view is expressed in it’s superview’s coordinate system. So you are centering your image view in the wrong coordinate system. (dynamic view’s superview as opposed to dynamic view)

    To centre view A within view B, the centre point of view A has to be the centre of the bounds rectangle of view B. You can get this using (from memory!) CGRectGetMidX and CGRectGetMidY.

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

Sidebar

Related Questions

I'm making an application for iPhone (which runs in landscape mode) (OS 3.0), and
I am making an application that does some custom image processing. The program will
I'm making my first iOS application to be run specifically on an iPad as
I'm making an application that will analyze real-time data that has been stored to
i'm making an application of tab bars...having 5 tabbars.i.e. home,ask,tip,inbox,disclaimer..now the problem is that
I am making an application which will retrieve all mailboxes from Domino Server. And
I'm making an application that will parse commands in Scala. An example of a
I am totally new to making ipad/iphone application. I am totally new to using
i am making an iPad application, i want to load 2 webPage on single
I am making my first iPad application, and I need to add the functionality

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.