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

  • Home
  • SEARCH
  • 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 7658137
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T13:09:45+00:00 2026-05-31T13:09:45+00:00

I am having a hard time understanding the following issue: This code does what

  • 0

I am having a hard time understanding the following issue:

This code does what i think it should do: Initialize badges, move it after the initialization and update label on the badge:

  • Initialize badge
  • Set value to 24 (or some other number)
  • Add UIView on screen
  • Change UIView location
  • Change value to read xx
[self initializeCardBadges];
[gameView addSubview:unplayedCountBadge];

[unplayedCountBadge setFrame:CGRectMake(315, 5, 25, 25)]; // Moves
unplayedCountBadge.badgeText = @"xx";                     // Updates label

where initializeCardBadges does the following:

self.unplayedCountBadge = [CustomBadge customBadgeWithString:[NSString stringWithFormat:@"%d", decks.masterDeck.count]
                                        withStringColor:[UIColor whiteColor] 
                                           withInsetColor:[UIColor redColor] 
                                         withBadgeFrame:YES 
                                    withBadgeFrameColor:[UIColor whiteColor] 
                                              withScale:1.0
                                             withShining:YES];  

[self.unplayedCountBadge setFrame:CGRectMake(435, 5, 25, 25)];

Once the badge is in place, we are free to move it around and change text. As mentioned above this works.

When i add a new method to update the badge labels, as expected, all is well again

[self initializeCardBadges];
[gameView addSubview:unplayedCountBadge];

[unplayedCountBadge setFrame:CGRectMake(315, 5, 25, 25)]; // Moves badge to location
[self updateBadgeLabelForUnplayedCards];                  // Updates label

-(void) updateBadgeLabelForUnplayedCards {
    unplayedCountBadge.badgeText=@"yy";    
}

But .. when i add the same logic to -(IBAction) doneWithThisRoundDealCards:(id)sender, upon button tap ..

[unplayedCountBadge setFrame:CGRectMake(315, 5, 25, 25)]; // Moves
[self updateBadgeLabelForUnplayedCards];                  // Value NOT set

Additionally, when i replace the above with explicit commands, the same can be observed: badge moves location, value is not set

[unplayedCountBadge setFrame:CGRectMake(315, 5, 25, 25)];  // Moves
self.unplayedCountBadge.badgeText=@"tt";                   // Value NOT set

Badge location changes, but … text does not update. Why is this?

I am reusing this code for badge generation.

Note that BadgeText is defined as a simple property, as shown here

@property(nonatomic,retain) NSString *badgeText;
  • 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-31T13:09:45+00:00Added an answer on May 31, 2026 at 1:09 pm

    did you try

    [unplayedCountBadge setNeedsDisplay];
    

    ?

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

Sidebar

Related Questions

I'm having hard time understanding the following C# code. This code was taken from
I'm having a hard time understanding why the following code doesn't work. I'm sure
I'm having a hard time understanding this. Consider the following example: protected void Page_Load(object
I'm having a hard time understanding why the following expression \\[B.+\\] and code returns
I'm having a hard time understanding the following statements from Algorithms by S. Dasgupta,
I'm having a hard time understanding how the CakePHP admin system works. Should all
I'm doing some homework, and having a hard time understanding closures. This is in
I am having a little bit of hard time understanding ScheduledTask[]. This was added
I am having a hard time understanding the following syntax in Verilog: input [15:0]
I'm having a hard time in understanding the unexpected output for the following program:

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.