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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T06:34:41+00:00 2026-06-08T06:34:41+00:00

Here is the problem – I have a class, which is a subclass of

  • 0

Here is the problem – I have a class, which is a subclass of UIView (a card). It creates a button on itself and it’s calling changeStateIndicator: when user touches it.

Then the card has to flip after the button is pressed and the button should change it’s color (actually, the image). But it’s not happening at all, so the flip starts before button has changed. Here is my code:

//Adding a button to my view
UIButton *changeStateButton = [UIButton buttonWithType:UIButtonTypeCustom];
[changeStateButton setImage:[UIImage imageNamed:imageToInitWith] forState:UIControlStateNormal];
[changeStateButton setImage:[UIImage imageNamed:imageToInitWith] forState:UIControlStateHighlighted];
changeStateButton.frame = CGRectMake(0, 0, 30, 30);
changeStateButton.center = CGPointMake(self.bounds.size.width/2+([myWord length]*8)+17, 35);
changeStateButton.tag = 77;
[changeStateButton addTarget:self action:@selector(changeStateIndicator:) forControlEvents:UIControlEventTouchUpInside];
[self addSubview:changeStateButton];

//Method which is called when the button is touched
- (void)changeStateIndicator:(UIButton *)sender
{
    [sender setImage:[UIImage imageNamed:@"StateYellow"] forState:UIControlStateNormal];
    [sender setImage:[UIImage imageNamed:@"StateYellow"] forState:UIControlStateHighlighted];
    currentWord.done = [NSNumber numberWithInt:currentWord.done.intValue-10];
    [self prepareForTest];
}

//Method which flips the card
- (void)prepareForTest
{
    testSide = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"cal_small3"]];
    [UIView transitionFromView:self toView:testSide duration:0.5 options:UIViewAnimationOptionTransitionFlipFromRight completion:nil];
}

My guess is that the sender doesn’t change it’s image until the method -changeStateIndicator comes to it’s end, but I’m not pretty sure this is the actual problem. Help me please.

  • 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-08T06:34:42+00:00Added an answer on June 8, 2026 at 6:34 am

    try just deferring this call:

    dispatch_async(dispatch_get_main_queue(), ^{ [self prepareForTest]; });
    

    If that sort of works but its still not how you want it, then use dispatch_after() or

    [self performSelector:@selector(prepareForTest) withObject:nil afterDelay:0.25f];
    

    (You can use the second call with a time of “0” instead of the dispatch if you want – same thing.)

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

Sidebar

Related Questions

Unusual problem here: I have an app that uses a text file which contains
I have a problem here im trying to upload a file first time it
I have a problem here. My Zend_Forms do not render in view script. Via
I have a problem here I can't solve. I have a database of houses
Here the problem: the layer gets sucessfully hidden, but when I click the button
Here the problem. I have my site hosted on a shared hosting for asp.net
hi all i have implemented code as shown in the below here problem is
Here's my problem, say, for example, I have a link on my page, it
I Have a problem here. i wanna to test my parser result. i have
I have here problem with my tail recursion Fibonacci in Ruby. When I run

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.