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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:23:06+00:00 2026-05-25T11:23:06+00:00

I was wondering how to detect whether the button was hidden or not, and

  • 0

I was wondering how to detect whether the button was hidden or not, and how much alpha was applied to it. Then, when viewDidLoad is called, these values can be applied to make the buttons the same state they were left in when the application closed.

How can I code this?

Thanks,

James

  • 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-25T11:23:06+00:00Added an answer on May 25, 2026 at 11:23 am

    If, as your title suggests, you want to use NSUserDefaults, then you can set them like this:

    -(void)saveButtonState:(UIButton*)button {
        NSUserDefaults defaults = [NSUserDefaults standardUserDefaults];
        [defaults setBool:button.hidden forKey:@"isHidden"];
        [defaults setFloat:button.alpha forKey:@"alpha"];
    }
    
    -(void)restoreButtonState:(UIButton*)button {
        NSUserDefaults defaults = [NSUserDefaults standardUserDefaults];
        button.hidden = [defaults boolForKey:@"isHidden"];
        button.alpha = [defaults floatForKey:@"alpha"];
    }
    

    If you want to do this for multiple buttons, then you can use tags to differentiate between them in the defaults:

    -(void)saveButtonState:(UIButton*)button {
        NSUserDefaults defaults = [NSUserDefaults standardUserDefaults];
        [defaults setBool:button.hidden forKey:[NSString stringWithFormat:@"isHidden%d",button.tag]];
        [defaults setFloat:button.alpha forKey:[NSString stringWithFormat:@"alpha%d",button.tag]];
    }
    
    -(void)restoreButtonState:(UIButton*)button {
        NSUserDefaults defaults = [NSUserDefaults standardUserDefaults];
        button.hidden = [defaults boolForKey:[NSString stringWithFormat:@"isHidden%d",button.tag]];
        button.alpha = [defaults floatForKey:[NSString stringWithFormat:@"alpha%d",button.tag]];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was wondering if it is possible to detect whether or not my Android
I'm new to jquery and was wondering: is a simple way to detect whether
I was wondering how I can detect code plagiarism with Javascript. I want to
I'm wondering if it's possible to detect whether a browser is running on iOS,
I was wondering whether there is a way to detect a touch in an
Wondering how does an application like Process Explorer or Combo Fix detect hidden process
I was wondering if there is a way I can detect the exact Operating
You can detect whether a popup has been blocked in Chrome with the solutions
Is there a programmatic, non-private-API way to detect whether the mouse cursor is hidden
I am wondering whether what I want can be acheived by using Yahoo pipes

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.