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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T14:36:07+00:00 2026-06-14T14:36:07+00:00

I noticed that sometimes on viewDidLoad I got the view size right. Sometimes I

  • 0

I noticed that sometimes on viewDidLoad I got the view size right. Sometimes I don’t.

For example

- (void)viewDidLoad
{
    [super viewDidLoad];
    self.pullToRefreshController = [self.pullToRefreshController initWithDelegate:self];
    PO(self.view);
    PO(self.view.superview);
    PO(self.view.superview.superview);
    PO(self.view.superview.superview.superview);

    while(false);
}
-(void)viewWillLayoutSubviews
{
    PO(self.view);
    PO(self.view.superview);
    PO(self.view.superview.superview);
    PO(self.view.superview.superview.superview);
    while (false);
}

at viewDidLoad the size of self.view is still 320 to 480. At viewWillLayoutSubviews that have been fixed.

I wonder what happen in between and where should I initialize stuffs? Or what stuffs should be in viewDidLoad and what stuffs should be in viewWillLayoutSubviews?

  • 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-14T14:36:08+00:00Added an answer on June 14, 2026 at 2:36 pm

    viewDidLoad is a good place to create and initialize subviews you wish to add to your main view. It is also a good place to further customize your main view. It’s also a good place to initialize data structures because any properties should have been set on the view controller by the time this is called. This typically only needs to be done once.

    viewWillLayoutSubviews is where you position and layout the subviews if needed. This will be called after rotations or other events results in the view controller’s view being sized. This can happen many times in the lifetime of the view controller. You should only layout the views here.

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

Sidebar

Related Questions

I've noticed, that sometimes (I don't know exactly when and why) system recreates my
When plotting in R using ggplot, I've noticed that sometimes if you don't specify
I have noticed that sometimes people have to use multiple versions of jQuery in
I am reading up about Encoding and Decoding and I noticed that sometimes people
I just started with backbone.js, and one thing that I noticed is that sometimes
I've noticed that initial comment in JavaScript or CSS files is sometimes started with
I have noticed that my application's Document folder is sometimes different. The workflow was
I noticed, that sometimes (especially where mod_rewrite is not available) this path scheme is
I noticed that sometimes(randomly) my Mootools ajax request gets send twice. The second request
I've noticed that sometimes commands can be tab completed. e.g. the xm command in

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.