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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:57:02+00:00 2026-05-27T21:57:02+00:00

I have a very simple issue, but I am not able to find the

  • 0

I have a very simple issue, but I am not able to find the reason for this bug. Any ideas appreciated.

So, I have an object of UIImageView and flick it (move it) from Point A(x1,y1) to Point B(x2, y2) to Point C(x2,y2), and so on….

When I move it from A to B to C to D and so on… WITHOUT ANIMATION, it works !

When I move it from A to B to C …. and so on… WITH ANIMATION -> There is a bug ! Only A to B works, B to C,… and so forth appears some place else.

I basically implement the touchesBegan method, and touchesEnd method and move the object to the new location with

//NO ANIMATION  ==> Works !

-(void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
    NSLog(@"End of touch");

    UITouch *touch = [[event touchesForView:self.view] anyObject];
    CGPoint location = [touch locationInView:touch.view];

    object.center = CGPointMake(location.x,  location.y); 

}

..

//ADDING ANIMATION ==> Bug ! 

-(void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
    NSLog(@"End of touch");

    UITouch *touch = [[event touchesForView:self.view] anyObject];
    CGPoint location = [touch locationInView:touch.view];

    [self spinLayer:object.layer duration:1 direction:SPIN_CLOCK_WISE newFrame:location];
    tempFrame = location;   // tempFrame is global. 
}

And at the end of animation, I do

- (void)animationDidStop:(CAAnimation *)theAnimation finished:(BOOL)flag {

object.center = tempFrame;

// I assign this because the object has to be updated to its new location to move it to points B, C, D and so forth...

// The object is actually at the desired point. But it appears on the SCREEN at a different location although it `NSLogs` at the right point.

}

This is the bug :

When I assign object.center = tempFrame; I expect the object to be at (x2,y2). It is technically at (x2,y2) (when I NSlog the location, I found out), but it appears elsewhere on the screen.

If I again move it to Point C, it uses (x2, y2) and correctly moves to (x3,y3), but it appears somewhere else on the screen again !

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-27T21:57:02+00:00Added an answer on May 27, 2026 at 9:57 pm

    Instead of using animatio transform.translation.x and transform.translation.y key paths I’d suggest using position.x and position.y keypaths.
    So, change the fragment

    theAnimationX=[CABasicAnimation animationWithKeyPath:@"transform.translation.x"];
    theAnimationX.toValue=[NSNumber numberWithFloat:(newFrame.x-object.center.x)];
    theAnimationY=[CABasicAnimation animationWithKeyPath:@"transform.translation.y"];
    theAnimationY.toValue=[NSNumber numberWithFloat:(newFrame.y-object.center.y)];
    

    to

    theAnimationX=[CABasicAnimation animationWithKeyPath:@"position.x"];
    theAnimationX.toValue=[NSNumber numberWithFloat:newFrame.x)];
    theAnimationY=[CABasicAnimation animationWithKeyPath:@"position.y"];
    theAnimationY.toValue=[NSNumber numberWithFloat:(newFrame.y)];
    

    You can also use just position keypath in this case (and set CGPoint as toValue)

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

Sidebar

Related Questions

This should be very simple, but its very frustrating. I have a LinqToSql as
I'm stuck with very simple but annoying issue, and cannot find answer on the
This is a very simple issue of CSS specificity, but I really can't figure
I have a very large ASP.NET application in C#. The issue is simple yet
I have this very simple jQuery function: $(.milestone-in-tree).live({ mouseenter: function() { setTimeout( $.ajax({ type:
I appear to have a named pipes 101 issue. I have a very simple
Very simple question this time, basically I have a group of folders and some
I find git docs very cryptic regarding this issue. I want to do a
I have very simple piece of code. The goal is when i input four-digit
I have very simple OpenGL ES example similar to Hehe's example : http://nehe.gamedev.net/tutorial/ios_lesson_02__first_triangle/50001/ As

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.