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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T20:23:41+00:00 2026-06-17T20:23:41+00:00

I am trying to make a UIButton display an image and am getting the

  • 0

I am trying to make a UIButton display an image and am getting the Title error.

Also I would like to know why () is needed on BSViewController () as it was created by XCode?

//
//  BSViewController.m

#import "BSViewController.h"

@interface BSViewController ()    // Why the "()"?
@end

@implementation BSViewController


- (IBAction) chooseImage:(id) sender{


    UIImageView* testCard = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"ipad 7D.JPG"]]; 
//Property 'window' not found on object of type 'BSViewController *'
    self.window.rootViewController = testCard;
    [self.window.rootViewController addSubview: testCard];
    testCard.center = self.window.rootViewController.center;

     NSLog(@"chooseImage");

}


- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end



//
//  BSViewController.h

#import <UIKit/UIKit.h>

@class BSViewController;
@interface BSViewController : UIViewController
<UIImagePickerControllerDelegate, UINavigationControllerDelegate>{
    IBOutlet UIButton* chooseImage;
}


- (IBAction) chooseImage:(id) sender;

@end
  • 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-17T20:23:42+00:00Added an answer on June 17, 2026 at 8:23 pm

    This line:

        self.window.rootViewController = testCard;
    

    Is an attempt to assign an imageView object pointer to an existing viewController object pointer. You should have got a compiler warning about that. Then on the next line you effectively try to add it to itself as a subview, that probably kicks up a warning as well.

    The () indicate a category extension to a class. It’s an extension to your public interface which allows you to declare entities that should be private to the class. You should put most of your interface here, just keep things in your .h @interface that need to be public.

    Your BSViewController class does not have a property called window so you cannot refer to it as self.window. But under normal circumstances you should be able to get a reference to your window like this:

        UIWindow* window = [[UIApplication sharedApplication] keyWindow];
        [window.rootViewController.view addSubview: testCard];
    

    However, if you just want to put testCard into your instance of BSViewController you don’t need to do that. You just need a reference to your current instance’s view:

        [self.view addSubview:testCard];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to make custom control (like UIButton) manually which can recognize user's touch.
I am trying to make a uibutton that has an image in it pulsate
I'm trying to make a UIButton with a background image where the image is
Trying to make the infamous checkall checkbox for dynamically created rows from a MySQL
Trying to make a simple number clicker control for BlackBerry 6/7, like this: At
I am trying to make a UIButton that grows when pressed. Currently i have
I am trying to make a series of numbers on different UIbutton e.g 1-10
I are trying to make to a stopwatch app and facing problems getting it
I'm trying make a JFileChooser for selecting a folder. In this FileChooser, I'd like
I'm trying to make my UIButton on my Navigation Controller bar. However, when I

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.