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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T19:57:47+00:00 2026-05-28T19:57:47+00:00

I do everything programmatically when developing for the ios, so I manually initialize the

  • 0

I do everything programmatically when developing for the ios, so I manually initialize the view controllers view in loadView for all of my view controllers (this is what Apple says to do). What frustrates me about doing it this way is the viewcontrollers frame initially is {{0, 20}, {320, 460}} not correctly accounting for any navbars or tabbars I have in my app. The view finally sets its proper frame in viewDidAppear, but by that time it’s too late to do anything. Is there anyway to make it recognize the view layout earlier without having calculate it manually?

It’s frustrating because I always have to manually check to see if the phone is in landscape or portrait mode to account for rotation, and if I have to set up my subviews in a specific way that I can’t do with autoresizing, then I also have to do manual calculations.

Is there any pattern that apple recommends for doing this, or is there anyway to get it to recognize the view layout earlier without having to calculate it manually?

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

    If you are using iOS 5, you should get passed the correct frame in the viewDidLayoutSubviews and viewWillLayoutSubviews methods of your UIViewController subclass. This is where you should calculate your layout, and they are called when the device rotates.

    Otherwise, viewWillAppear exists from iOS 2.0, and my test app shows that it is passed the proper frame. It doesn’t solve the rotation mid-run, but presumably you can just hook into that elsewhere. You aren’t meant to set up your views that late in the game, but other than playing around with layoutIfNeeded from viewDidLoad (that I didn’t manage to get working in the past) I don’t know what you are supposed to do pre iOS5.

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

Sidebar

Related Questions

I'm creating my view hierarchy programmatically in loadView in my ViewController. I have to
Everything I have read says that when making a managed stored procedure, to right
Everything I read about better PHP coding practices keeps saying don't use require_once because
Everything is an object was one of the first things I learned about Ruby,
Friends, i m developing a Game. All the drawings are handled by my sSurfaceViewClass,
I'm making a UIControl subclass and therefor programmatically laying out everything in it. Now
I have a WinForms group box that needs to be sized programmatically. Everything else
I've done everything programmatically. When I rotate the device from landscape to portrait though,
I've programmatically created some UINavigationControllers and added them to a UITabBarController. Everything seems to
i am developing a simple view based application which contains two buttons and a

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.