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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T16:42:07+00:00 2026-06-07T16:42:07+00:00

Today animateWithDuration was acting really stupid and I don’t know why really. I checked

  • 0

Today animateWithDuration was acting really stupid and I don’t know why really. I checked all the things, all the brackets and everything was perfect, but it was always presenting the line of code i didn’t specify as an animation.

Ok, so here’s the point. I have a longPressGestureRecognizer. It’s on some UIImageView, which is being dragged, after the longPress begins. When it ends in some special zone I want to start the animation, taking the UIImageView to some other place and finish it. Here’s my code:

if ([(UILongPressGestureRecognizer*)sender state] == UIGestureRecognizerStateEnded) {
    CGPoint dropPoint = CGPointMake(self.center.x, self.center.y-5);
    for (UIView * placeForCharacter in delegate.subviews) {
        if ([placeForCharacter isKindOfClass:[PlaceForCharacterCircle class]]) {
            PlaceForCharacterCircle * newPlaceForCharacter = (PlaceForCharacterCircle *) placeForCharacter;
            if (CGRectContainsPoint(newPlaceForCharacter.dropZone, dropPoint)) {
                    UIViewAnimationOptions options = 0;
                    [UIView animateWithDuration:0.2 delay:0.0 options:0 animations:^{
                        self.frame = CGRectMake(newPlaceForCharacter.frame.origin.x-8, newPlaceForCharacter.frame.origin.y-5, 40, 55);
                        self.alpha = 0.5;
                    } 
                    completion:^(BOOL finished){
                        NSLog(@"animation completed");
                        self.alpha=1;
                        //code referring to the finalizing of moving, doesn't matter here
                        return;
                    }];
            } else {
                if (CGRectContainsPoint(newPlaceForCharacter.dropZone, dropPoint)) {
                    //code referring to the moving to the other place in case the UIImageView was dropped on another zone that is full already, doesn't matter here
                    return;
                }
            }
        }
    }
        //code referring to the comeback of a UIImageView in case it was dropped somewhere else, doesn't matter here
        //These two are the lines that get executed when the animation starts
        //THEY BEGIN
        translatedPoint = CGPointMake(initialX, initialY);
        [[sender view] setCenter:translatedPoint];
        //THEY END
        return;
}

The case is that for some strange reason the two lines of code above get animated instead of the REAL animation, that was specified. I double-checked it by putting the comments on these lines of code – in this case the animation works just fine.

Could someone please clear this out for me, why does this happen? It seems to be a really strange behaviour.

  • 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-07T16:42:09+00:00Added an answer on June 7, 2026 at 4:42 pm

    If you move the return; from the completion block (where it’s not doing anything) to after the animation is setup it should work.

    [UIView animateWithDuration:0.2 delay:0.0 options:0 animations:^{
        self.frame = CGRectMake(newPlaceForCharacter.frame.origin.x-8, newPlaceForCharacter.frame.origin.y-5, 40, 55);
        self.alpha = 0.5;
    }
    completion:^{
        NSLog(@"animation completed");
        self.alpha=1;
        //code referring to the finalizing of moving, doesn't matter here
    }];
    return;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

today i hit a really annoing problem with wpf. i just want to align
I don't mean to start a code formatting holy war here, but I'm wondering
Today we have received some strange exceptions on our production website. They all have
today i forced to reinstall wamp on my pc. but i forgot to copy
Today I tried to use const indentifier, but I find the const variable can
Today I wanted to write a simple php script, but I got some annoying
Today i faced a little problem, i wanted to know the reason of leak.
today I was trying to use the SnowballAnalyzer on Lucene Java API v3.6.0 but
Today I encountered a bug (in PDO) I never saw before, but is kinda
Today I was working in C# and tried to catch a FileNotFoundException . But

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.