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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T02:14:03+00:00 2026-06-16T02:14:03+00:00

I am checking an image of button to get its state, like this: if([syncBtn.currentImage

  • 0

I am checking an image of button to get its state, like this:

if([syncBtn.currentImage isEqual:[UIImage imageNamed:@"playbtn1.png"]])
{
  //Do something if play button
}
else if([syncBtn.currentImage isEqual:[UIImage imageNamed:@"syncbtn1.png"]])
{
  //Do something if sync button
}
else 
{
   //do something when no image on button
}

There is always an image on button either syncbtn1.png or playbtn1.png.

This above check is working fine but when I go to backgroud & then return to foreground then only its not able to check the button’s current image from above method, its going in else condition.

What could be wrong?

  • 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-16T02:14:05+00:00Added an answer on June 16, 2026 at 2:14 am

    This is because you are comparing the UIImage instances. They are cached by default, so you get the same instance most of the time. But after the app has been to the background, the cache is cleared and you get a new instance, what means it is not matching anymore.

    Two options to fix it..

    Using your current way:

    1. Create your image instances only once and save them in a strong property.
    2. Assign these images to your button and also check against these instances.

    Using button states:

    1. Set the playbtn1.png image for the UIControlStateNormal
    2. Set the syncbtn1.png image for the UIControlStateSelected
    3. Now just set and check for syncBtn.selected – the images will change automatically, if you change the selected flag.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is it possible to get the size of an image (probably its size in
I have added an image for my button,but when I run that frame this
I have a simple script which displays one button (which is a png image)
I'm trying to open an image from a specific uri, checking if this image
Checking few RDBMS I find that things like SELECT COUNT (a), SUM (b) FROM
When checking for nulls I use this: String str; if(str == null){ //... }
when checking the source code of a site on firefox I got this on
I have a problem in creating a Button with text and image on it.
I've been using this little snippet to select random images. However I would like
I'm trying to get Text from a dynamically craeted server textbox. I'm just checking

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.