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

  • SEARCH
  • Home
  • 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 8483327
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T20:04:20+00:00 2026-06-10T20:04:20+00:00

I am trying to add a UILabel in UIWindow of AppDelegate from a UIViewController.

  • 0

I am trying to add a UILabel in UIWindow of AppDelegate from a UIViewController. This is how I am doing this:

AppDelegate code :

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
    // Override point for customization after application launch.
    if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
        self.viewController = [[[ViewController alloc] initWithNibName:@"ViewController_iPhone" bundle:nil] autorelease];
    } else {
        self.viewController = [[[ViewController alloc] initWithNibName:@"ViewController_iPad" bundle:nil] autorelease];
    }



    [self.window makeKeyAndVisible];

    self.window.rootViewController = self.viewController;


    return YES;
}

ViewController code :

- (void)viewDidLoad
{

    UILabel *abcd=[[UILabel alloc] initWithFrame:CGRectMake(100.0, 100.0, 200.0, 40.0)];

    abcd.text=@"loading...";

    abcd.backgroundColor=[UIColor clearColor];

    [[[[UIApplication sharedApplication] delegate] window] addSubview:abcd];

    [super viewDidLoad];


}  

But all I am seeing is grey screen but no label. Where I might be going wrong?

  • 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-10T20:04:21+00:00Added an answer on June 10, 2026 at 8:04 pm

    1) I suggest you reverse the order of your last two delegate statements:

    self.window.rootViewController = self.viewController;
    [self.window makeKeyAndVisible];
    

    2) While you should be able to add the label to the window, its somewhat unorthodox to do so. In any case, try adding the label to the viewController’s view and see if that works, and if so, and you really want to add it to the window (for some reason), then add a comment here:

    [self.view addSubview:abcd];
    

    If you still cannot see the label its likely that there is an issue with the view controller. Did you define anything in the nib – any element that should be visible at launch ? If not then add something just so you can be sure the view is in fact getting loaded. [One trick I use is to set the background color of views to red or blue, so I can see that in fact they got loaded.]

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

Sidebar

Related Questions

I am trying to add elements to a scroll view using this code: int
I'm trying to add a custom view to an UITableView created with code from
I'm trying to add a UILabel to my UIScrollView , but it doesn't show
I am trying add picture boxes dynamically. My code is as PictureBox picture =
I am trying to add a UILabel anagrammatically like below - (void)viewDidLoad { [super
Trying to add text to QGraphicsView: Widget::Widget(QWidget *parent) : QWidget(parent), ui(new Ui::Widget) { ui->setupUi(this);
I'm trying to add some UI elements like UIProgressView , UILabel , UIButton and
I'm trying to add objects to this NSArray (labelArray) but for some reason, it
I'm trying to add an extra UILabel into each cell( UITableView ) I'v succeeded
I'm trying to add number from 1 to 9 from plist to each cell

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.