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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T22:30:05+00:00 2026-05-16T22:30:05+00:00

I have a project where there are 64 buttons, you have to click certain

  • 0

I have a project where there are 64 buttons, you have to click certain ones, then click ‘done’. If you clicked the right ones, you get some points, and those then need to disappear.
I have let the user keep track of which buttons are pressed by doing sender setSelected:TRUE.
The first bit is all working fine, but I’d like to be able to then hide the buttons that were selected when the user clicked ‘done’.

My current thoughts are:
– what I used in Actionscript to do the same thing was

for (i=1;i++;i<65) {
if(getProperty (“b”+ i, _visible) == true) {do blah blah blah} }

I’m really really really hoping there is an obvious equivalent in objective C that does the same thing?

I definitely do not want to have to go through all 64 buttons and type if ([b1 isSelected == TRUE]etc…
I can’t just use sender, as it may be several buttons that have previously been selected that I need to access.

EDIT –
This is now the code that is called when user presses one of the 64 buttons.

        -(IBAction) pressed:(id)sender {
        UIButton *button = (UIButton *)sender;
        if ([sender isSelected] ==FALSE) {  
            [sender setSelected:TRUE];  
        }
        else {
            [sender setSelected:FALSE];
        }
            if ([myArray containsObject:sender])
            {
                [myArray removeObject:sender];
            }
            else {
                [myArray addObject:sender];
            }
    }

This is called when they press the ‘done’ button.

-(IBAction) checkTotal:(id)sender {

if (total == [(totaltxt.text) intValue]) {
    score += 1;
    scoretxt.text = [NSString stringWithFormat:@"%i", score];
    for (UIButton *b in myArray)
    {
        [b setHidden:TRUE];
    }
    [myArray removeAllObjects];
    }

else {
    // some indication that they pressed the button but were wrong.
}

}

It unfortunately still won’t hide the button.
It works if I change it to [n1 setHidden:TRUE] to hide the matching textbox above the button, but won’t hide even a specific button -eg- [b1 setHidden:TRUE], let alone all the buttons in my array.
AAAAAAAARGH!!!!
Any ideas?

  • 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-16T22:30:05+00:00Added an answer on May 16, 2026 at 10:30 pm

    You can iterate on your view’s subviews, and check whether the subview is a button:

    for (UIView *view in self.view.subviews)
    {
        if ([view isKindOfClass: [UIButton class]])
        {
            // Do processing here
            // For instance:
            if ((UIButton *)view).isSelected)
                view.hidden = YES;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I have a project where there is some automatic initialization going on through
I have one java project in netBeans. There are some packages, and classes in
I have a project where there are Windows, FreeBSD and Linux servers. I have
I currently have the DatePicker in my project but there are problems due to
I have a project that I am working on in django. There are a
I have a project with a main MDI form. There is a child MDI
I have my project folder, for instance, myWeb . In it there are various
I have a mvc project and on one page there is a table of
I have a Maven project with JavaScript code. There is a special javascript compiler
I have a web project in Asp.net MVC where in many pages, there 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.