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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T19:01:24+00:00 2026-06-05T19:01:24+00:00

I ran into a problem that suggests I may be implementing a design pattern

  • 0

I ran into a problem that suggests I may be implementing a design pattern improperly. I have dynamic subviews whose sizes are language dependent. When I present a modal view, I set the layout during viewDidLoad. I noticed that a UILabel object was not dispalying correctly and found the problem to be that the size of the modal view during viewDidLoad is not the same as the size when the view is shown.

The width of the modal view during viewDidLoad s 768. After the view has appeared, the width is 540.

This suggests that I should be setting layout during viewWillAppear, and not during viewDidLoad.

This seems to contradict my understanding of the DRY principle, if I apply it to execution, as the layout isn’t going to change once the view is loaded, so I would be unnecessarily repeating the layout code every time the view appears. (I know that in my example, the language setting could be changed in between presentations of the modal, but there may be other examples where this type of dynamic doesn’t exist.)

I implement the layout in non-modal views the same way — in viewDidLoad.

Should I be doing this differently?

  • 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-05T19:01:26+00:00Added an answer on June 5, 2026 at 7:01 pm

    Assuming a view won’t change is incorrect. For example, when changing orientation. Usually setting your view in viewDidLoad, in conjunction with correct auto resizing mask, is sufficient in most cases. If you need finer control of setting up when the view resizes, you should override viewWillLayoutSubviews/viewDidLayoutSubviews, and rearrange your views there. So in viewDidLoad you would add your subviews and et their content, then in layout set their sizes and positions.

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

Sidebar

Related Questions

Today I ran into the following problem with NUnit. I have a class, that
I have recently ran into a problem that would not allow me to use
I have ran into a problem that i suspect has to do painting/drawing elements
All, I ran into this problem where for a UITextField that has secureTextEntry=YES, I
A problem I recently ran into was that when trying to update a field
Never ran into this problem with jQuery before. I have the following: $(document).ready(function() {
I ran into a problem that I need to access to private field of
I'm currently messing around in FORTRAN 77 and I've ran into a problem that
I ran into a problem that occurs when using the module PanedWindow Tix. Let's
I ran into a problem that is very similar to other SO question (

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.