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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T05:32:35+00:00 2026-06-09T05:32:35+00:00

Have an AppDelegate and a MainViewController . In MainViewController the UIButton was created, AppDelegate

  • 0

Have an AppDelegate and a MainViewController.
In MainViewController the UIButton was created, AppDelegate sets a background image and should show it on MainViewController. That’s pretty much it but I can’t see the UIButton.

Just for alignment purpose I created an IBOutlet and connected the button in IB.

MainViewController.h

@property (strong, nonatomic) IBOutlet UIButton *searchBtn;

MainViewController.m

@synthesize searchBtn;

AppDelegate.m

@synthesize mainVC;


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    // ViewController > setup:
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    self.mainVC = [[MainViewController alloc] initWithNibName:@"MainViewController" bundle:nil];
    self.window.rootViewController = self.mainVC;
    self.window.backgroundColor = [UIColor whiteColor];

    // Buttons > Set background images:
    [self.mainVC.searchBtn setImage:[UIImage imageNamed:@"search.png"] forState:UIControlStateNormal];

    [self.mainVC.view addSubview:self.mainVC.searchBtn];

    [self.window makeKeyAndVisible];

    return YES;
}
  • 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-09T05:32:37+00:00Added an answer on June 9, 2026 at 5:32 am

    First you don’t need IBOutlet if you are creating it programmatically.

    Second you probably want to move the creation of the button in viewDidLoad of your view controller rather than in your AppDelegate. It’s your view controller’s business.

    Third you should probably alloc init your button if you create it programmatically:

    UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(...)];
    [button setBackgroundImage:someImage];
    [button addTarget:self action:@selector(something:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:button];
    

    something like that.

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

Sidebar

Related Questions

I have an activity view that I have added in AppDelegate class to tap
I have a Tableview on AppDelegate That calls a SecondView (dvController) when DidSelectRowAtIndexPath using:
I have a variable set for my AppDelegate which stores the current URL that
In my appDelegate.m I have this code, but the UILabel is not displaying, but
I have setup coredata in my appDelegate, but it first loads the mainWindow.xib and
I have a pretty simple question, but am still finding my way around cocoa.
I created an app in where i have appdelegate class only. I dont create
I have an appDelegate that init an instance of a class called LocationService. I
I have some class initialized in Appdelegate, but when I get this class instance
I am a very inexperienced developer and have run into a problem that should

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.