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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T04:24:57+00:00 2026-05-31T04:24:57+00:00

I am trying to add a View Controller to the Appdelegate Class. My code

  • 0

I am trying to add a View Controller to the Appdelegate Class. My code goes this way..

[self.view addsubView:viewcontroller.view];

But unfortunately i am not able to view the controller view. Please suggest if i am going wrong somewhere.Thanks for ur time.

The method in AppdidFinishLaunching is:-

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
    // Override point for customization after application launch.
    self.window.backgroundColor = [UIColor whiteColor];
    // [self.window addSubview:videoController.view];
    self.window.rootViewController = videoController;
    [self.window makeKeyAndVisible];    
    return YES;
}

and in the Load view of ViewController i have written as

UIButton *playMovie = [UIButton buttonWithType:UIButtonTypeRoundedRect];
playMovie.frame = CGRectMake(70,30,100,50);
[playMovie setTitle:@"Play Movie" forState:UIControlStateHighlighted];
[playMovie addTarget:self action:@selector(playMovie:) forControlEvents:UIControlEventTouchDown];
[self.view addSubview:playMovie];

The problem here is i am not able to view the button and the view.Please help.

  • 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-31T04:24:59+00:00Added an answer on May 31, 2026 at 4:24 am

    Under no circumstances should you ever add a view controller’s view manually to the interface like this. The app delegate is not, itself, a view controller; so viewcontroller is not its child. So the view is not yours to add. Use view controllers correctly: a view controller is either your app window’s rootViewController, or it is some other view controller’s child – and in either case, its view is placed into the interface for you automatically.

    If this view is intended to be the root view of the app, then do what the Xcode 4.2 project templates do (e.g. the Single View Application): instantiate the view controller and assign it as self.window.rootViewController. If not, you must not use a view controller to add it as a subview as you are trying to do; just obtain the view and add it, without the intervening view controller.

    It might help you to read my chapter on view controllers: http://www.apeth.com/iOSBook/ch19.html

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

Sidebar

Related Questions

I'm trying to add a custom root view controller (let's call it MyViewController )
Am trying to connect the App Delegate to the View Controller in Xcode4, but
I am basically trying to add two view controllers to one controller. I created
So in my view controller I am trying to add a table view to
I'm trying to add a button to a modal view controller so it can
I have been trying to add/implement this example to my existing Split View app
I'm trying to unload a view controller from view when the iPhone goes to
I am trying to add a view to a custom list. The target is
I am trying to add a custom view control to a custom UITableViewCell which
I'm trying to add a strongly-typed view to the sample app that's created when

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.