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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:20:32+00:00 2026-05-25T20:20:32+00:00

I have an UIButton with an image made with a white background and a

  • 0

I have an UIButton with an image made with a white background and a figure in the center. On click this image must be changed with another. The problem born when i click on button his background become light gray while it change the image. It happens only the first time i click. I made this app to play sound when i click on button and change the image. When the sound finishes to play, the image return to the original.

This is the viewDidLoad

- (void)viewDidLoad
{
    [super viewDidLoad];
    imageOpen = [UIImage imageNamed:@"aperto.jpg"];
    imageClosed = [UIImage imageNamed:@"chiuso.jpg"];
    CGRect rect = CGRectMake(([UIScreen mainScreen].bounds.size.width - imageOpen.size.width)/2,([UIScreen mainScreen].bounds.size.height - imageOpen.size.height)/2, imageOpen.size.width, imageOpen.size.height);
    [bottone setFrame:rect];
    [bottone setImage: imageOpen forState: UIControlStateNormal];  
    ...
}

This is the function called when the button is clicked:

- (IBAction)launchDialog
{  
    [bottone setImage:imageClosed forState: UIControlStateNormal];
    if(self.player.playing==TRUE){
        [self.player stop]; 
    }
    self.player.currentTime = 0;
    [self.player play];
}

And this is the method called when the sound finishes to play:

- (void)audioPlayerDidFinishPlaying:(AVAudioPlayer *)player successfully:(BOOL)flag {
    [bottone setImage: imageOpen forState: UIControlStateNormal];
}

What is the problem? what can i do?

  • 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-25T20:20:32+00:00Added an answer on May 25, 2026 at 8:20 pm

    You need to set all the states of your button. Did you do that where you indicate that you are configuring the button with //...?

    These are the four states that you have to set:

    UIControlStateNormal               
    UIControlStateHighlighted          
    UIControlStateDisabled             
    UIControlStateSelected    
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have customized UIButton with the following properties: 84x44 frame 84x44 background image 32*32
I have one UIButton . I put one image on that. When I click
I have a UIButton, and I'm adding an image to it using this code:
How do you set the image for a UIButton in code? I have this:
I have written this code to see different image states... UIButton *btnComment = [UIButton
I have an iPhone UIButton (Custom) which has a background image and text. When
I have UIButton that I set the background image for three states, normal, highlighted,
I have a custom UIButton in my viewcontroller that should have either the image
i have an UIButton with Custom style and a default image. When i press
i have to change the back button image. So for achieveing this i am

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.