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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T10:33:01+00:00 2026-06-07T10:33:01+00:00

I’ve just started programming and I’ve got this far but I’ve been struggling with

  • 0

I’ve just started programming and I’ve got this far but I’ve been struggling with this now for a while and am completely stuck. I’ve created a 10×10 board of playing cards, from two decks. I’ve then made them all buttons in -(void)displayBoard below. Each card has a BOOL property card.button holding whether it should be enabled as a button or not.

I’m switching them on OK and all works fine. They start off untouchable, then I switch them on and they correctly call (void)boardCardPressed. However, when I switch them off there they graphically appear to be off, but are still calling (void)boardCardPressed when I touch them. If I log the button property, that is being set correctly. I suspect it’s something to do with me adding the target and not removing, but everything i try makes no difference.

I’ve not found any help on this anywhere so any ideas, tips or help would be very much appreciated. BTW – I suspect my attempts aren’t the most elegant, so tips there would be great too. It was the only way I could find to get my card images to be selectable 🙂

-(void)displayBoard{

    board = [model board];

    for (int x = 0; x < 10; x++){
        for(int y = 0; y < 10; y++){
            Card *tCard = [board getCardxpos:x ypos:y];

            UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
            button.tag = tCard.tag;            
            button.enabled = tCard.button;            

            button.adjustsImageWhenDisabled = NO;

            [button setImage:tCard.image forState:UIControlStateNormal];             

            button.frame = CGRectMake(tCard.xPos, tCard.yPos, tCard.sizeW, tCard.sizeH);            
            [button setImage:tCard.image forState:UIControlEventTouchUpInside];

            [button addTarget:self action:@selector(boardCardPressed:) forControlEvents:UIControlEventTouchUpInside];

            [(SequenceView *)self.view drawIt:button];    
        }   
    }
}


-(void)boardCardPressed:(id)sender {

    int tid = ((UIControl*)sender).tag;    
    int x = tid / 10;
    int y = tid%10;
    Card *tCard = [[model board] getCardxpos:x ypos:y];

    tCard.chosen = YES;
    tCard.button = NO;

    [self displayBoard];

}
  • 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-07T10:33:04+00:00Added an answer on June 7, 2026 at 10:33 am

    There is something that is not entirely clear to me in your code. As far as I see, you create the displayBoard and includes 100 buttons in it; when any of those buttons is touched, the boardCardPressed is called again and you create again the board, with its 100 buttons that have nothing to do with the original ones.

    Is this meant to be so? Or could this have to do with the behavior you don’t understand?

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

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I've got a string that has curly quotes in it. I'd like to replace
I have this code to decode numeric html entities to the UTF8 equivalent character.

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.