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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T16:11:06+00:00 2026-05-20T16:11:06+00:00

I’m having a lot of trouble doing something very simple. I have a viewController

  • 0

I’m having a lot of trouble doing something very simple. I have a viewController and a subViewController, both with views loaded from nibs. For clarification the parent view is sized 1024 by 748 and the subView is 640 by 480 in the nibs.

On the viewController’s viewDidLoad I add the subViewController’s view like so:

[self.view addSubview:self.subViewController.view];
NSLog(@"subview.frame:%@",NSStringFromCGRect(self.subViewController.view.frame));

The log outputs:

subview.frame:{{0, 0}, {640, 480}}

Then, just to test things out, I use setCenter to attempt to reposition the subview within the parent view at the same position like so:

CGPoint newCenter = CGPointMake(0,0);  //should stay at the same position..
[self.subViewController.view setCenter:newCenter];
NSLog(@"after changing center.subview.frame:%@",NSStringFromCGRect(self.subViewController.view.frame));

The log outputs:

after changing center. subview.frame:{{-320, -240}, {640, 480}}

Now I have a feeling that something might be getting screwed up in the nibs and am guessing it’s something to do with the springs & struts / size & position options. I can only guess it’s this because this is the feature I have least understanding of when it comes to IB.

Any other ideas as to what could be causing this issue? Do you guys have any tips in general on how to set up viewcontrollers’ views in IB so that they are automatically positioned in alignment with other viewcontrollers’ views? And after setting things up, is setCenter the correct way of moving them around dynamically?

  • 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-20T16:11:06+00:00Added an answer on May 20, 2026 at 4:11 pm

    The outputs are correct given what you are doing. The point (0,0) is the top-left corner. If you set the center of subview to this, then the top left corner of the subview will indeed be (-640/2, -480/2).

    To get the top-left corners to align, use

    [self.subViewController.view setCenter:CGPointMake(320.0,240.0)];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and

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.