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

The Archive Base Latest Questions

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

I set views programmatically. Here is how I do that. Let’s say I have

  • 0

I set views programmatically. Here is how I do that. Let’s say I have SettingsViewController.m

In this file I have two methods

-(void)loadView
{
UIView *view = [[UIView alloc] initWithFrame:[UIScreen mainScreen].applicationFrame];

    self.view = view;
    [view release];
}

-(void)didViewLoad
{
//  In that method I create some buttons labels etc
}

Is my approach correct ? To create the view in loadView method and buttons, labels etc in viewDidLoad method

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

    To be honest it doesn’t really matter if you put the code for creating views in viewDidLoad or loadView. viewDidLoad is called after the view is loaded, so will even be called if you are instantiating from a XIB. So that’s a good place to add extra views if you’re using a XIB. If you’re programatically creating the view like you are in loadView then you can put the creation of your buttons, labels, etc in loadView or viewDidLoad and it won’t really make a difference – viewDidLoad is pretty much called straight after loadView runs anyway.

    Personally if I’m creating a view programatically using loadView then I will put all of the view creation code in there rather than in viewDidLoad.

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

Sidebar

Related Questions

We have a set of tables and views that merely store some config data
I have a very complex controller with a very complex set of views and
I have the whole MVC-Model set up and use HTML views as templates. But
I have a View set to grab the latest forum posts. That's working fine,
i have questions regarding the shake detection that posted here before, here is a
I have a custom UIComponent that is basically just this: public class WhiteboardUIComponent extends
I created a sample application that where I have a basic fullscreensize UIImageView set
I have the following app, that's like a chat, so I'm programmatically creating some
I have a programmatically created UIToolbar in a couple of views. In my view
This is a question that extends from the originally posted here: Link to loading-xaml

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.