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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T16:42:48+00:00 2026-05-28T16:42:48+00:00

Was just wondering how you all go about centering a subview in the viewcontrollers

  • 0

Was just wondering how you all go about centering a subview in the viewcontrollers main view while in loadView. I know the code for how to center it, but the problem is, while in loadView, the viewcontrollers main view frame is incorrect since it hasn’t resized it yet to fit in between my tabbar and navbar. So if I center a subview within it, it won’t be centered by the time the view appears. I did a little experimenting and it seems the viewcontrollers view sets its frame correctly somewhere after viewWillAppear is called and before viewDidAppear is called. Anyone have any insight on how I can accomplish this correctly while in loadView? (overriding layoutSubviews isn’t an option)

  • 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-28T16:42:49+00:00Added an answer on May 28, 2026 at 4:42 pm

    If you want to keep the subview always at the center, you should set the correct frame of your subview in either -viewDidLoad or -loadView, after the view property is correctly set, and set its autoresizingMask property to UIViewAutoresizingFlexibleLeftMargin|UIViewAutoresizingFlexibleRightMargin|UIViewAutoresizingFlexibleTopMargin|UIViewAutoresizingFlexibleBottomMargin.

    Also remember to set your superview’s autoresizesSubviews to YES, either from xib or your initialization code.

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

Sidebar

Related Questions

just wondering how I can get all the browser plugins object? I know about
Just wondering about this... I have several separate javascript files, that all contain code
I was just wondering how someone would go about finding all the applications that
Hey all, I'm just wondering if it is possible to get the name of
The questions says it all, just wondering, in an interview, what would you say
Just wondering if a .NET app can be compiled down to native machine code
I'm just wondering if its at all possible to add a UIButton or and
I am just wondering if these code blocks gets compiled into .dll I don't
I'm somewhat new to jQuery and am just wondering how I go about passing
UPDATE: thanks to all the answer given, but they are all about the system

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.