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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T12:42:17+00:00 2026-05-27T12:42:17+00:00

I have an app, where when the button is pressed, an action happens ..

  • 0

I have an app, where when the button is pressed, an action happens .. I can get the button to change when the action starts by using:

UIImage *changeImage = [UIImage imageNamed:@"stopGrey.png"];
[myButton setImage:changeImage forState:UIControlStateNormal];

After the action ends, I want to be able to change the button back.. I cannot figure out how to do this..

I’ve tried UIControlStateDisabled/Selected/Application.. I’ve logged to make sure the end of action is being received.

Thanks for any 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-27T12:42:18+00:00Added an answer on May 27, 2026 at 12:42 pm

    Ok, you need to do this:

    .h file:

    -(IBAction)ButtonPressed:(id)sender;
    -(IBAction)ButtonReleased:(id)sender;
    

    if you are using the graphical part join the touch down event to the method ButtonPressed and the touch up inside to ButtonReleased (right click the button for these options to appear). If you are using code to add the buttons use the method (in the viewdidload method of the .m file):

    [button addTarget:self action:@selector(ButtonPressed:) forControlEvents:UIControlEventTouchDown];
    [button addTarget:self action:@selector(ButtonReleased:) forControlEvents:UIControlEventTouchUpInside];
    

    Then you’re done. The method ButtonPressed will be called every time you touch the button and the ButtonReleased method will be called every time the you let go of the button inside of it. For your question, you can add the following code to the methods (.m file)

    -(IBAction)ButtonPressed:(id)sender
    {
        [button setBackgroundImage:[UIImage imageNamed:@"ImageWhenPressed.png"] forState:UIControlStateNormal];
    }
    -(IBAction)ButtonReleased:(id)sender
    {
        [button setBackgroundImage:[UIImage imageNamed:@"ImageWhenReleased.png"] forState:UIControlStateNormal];
    }
    

    I am also guessing that you don’t know how to link a button drawn in the graphical file to a pointer in the code. First you create a pointer in the .h file:

    IBOutlet UIButton *button;
    

    Then, you go to the graphical file and right click-drag the file owner image (on the left, has a orange-transparent cube as an image) to the button. Then, you select the option that has the name of the pointer. In this case, button.

    And there! you’re done!

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

Sidebar

Related Questions

I have an app with a quickaction shown once a button is pressed. The
I have a .NET application that contains a checkbox (System.Windows.Forms.Checkbox). This component (WindowsForms10.BUTTON.app.0.378734a1) is
Hello StackOverflow'ers, I have a (flex) app that, on the click of a button,
I'm now testing GKPeerPickerController. I have a simple app that just have a button
I have a button that launches the google maps app on my device via
I have a WPF app that is using the MVVM pattern. Hooking up buttons
I'm trying to avoid an app crash here... I have a button that will
I am using iOS 5 to implement an app. In this app I have
I have an android app with a button. When clicking the button I need
Currently, my app loads a UIImagePickerController when a button is pressed. I would like

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.