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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T23:55:35+00:00 2026-06-03T23:55:35+00:00

I have UIButton instance called card. I have an object called Representer, which has

  • 0

I have UIButton instance called card. I have an object called “Representer”, which has a property “image”, which is a UIImage. I’m trying to change the value of the button’s image at runtime. I have the button in interface builder, and also declare an IBOutlet with the button. I write this code :

UIButton *card1 = [[UIButton alloc] init]; 
[card1 setImage:representer.image forState:UIControlStateNormal]; 

When this code is compiled, the button’s image doesn’t change. Someone help me, please!

  • 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-03T23:55:37+00:00Added an answer on June 3, 2026 at 11:55 pm

    You first need to ensure that your button is connected to the IBOutlet in Interface Builder, have you done that with the Connections Inspector?

    If you have the button in your .h as:

    @property (nonatomic, retain) IBOutlet UIButton *option1Button;
    

    Then, in the .m file, call

    [option1Button setImage:representer.image forState:UIControlStateNormal];
    

    In your code, you are just instantiated another UIButton and setting the image on it. That is fine code but has nothing to do with the button in the xib.

    This definitely assumes the IBOutlet is correctly wired up in Interface Builder. Here’s how it should look:

    enter image description here

    Also, you need to be consistent in the button’s image, versus the button’s background image. They are two different things. If you have specified the “image” in Interface Builder, then do the same in your code, and vice versa with the backgroundImage.

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

Sidebar

Related Questions

I have a custom class, and that class has a UIButton instance variable. I
I have a problem with UIButton image if I set its imageView contentMode to
I have a method that accepts a sender and is called with a UIbutton.
Say for instance I have an IBAction that is hooked up to a UIButton
I have an application where I initially set a UIButton's background image, and then
i have an UIButton with Custom style and a default image. When i press
I'm running into an issue where I have a UIButton in which I want
I have a UIButton on a UIView. I want to programatically figure out which
What I'm trying to do is have a single function for each UIButton that
I have a UIButton in a UITableView cell, in a UITableView. The result is

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.