Note that there are some explanatory texts on larger screens.

plurals
  1. POUIButton always moves back to its first location?
    text
    copied!<p>I am having this hair pulling problem, i hope anybody will be able to help me out. it seems like a little thing but i have not been able to find any solution.</p> <p>I have a UIButton that i want to move around with a animation block. Everytime i click the button i have it move to a new location, the button always moves to the correct location the problem is that it always moves from its first location to its new location.</p> <p>lets say that i have a button at <code>(0,0)</code> i then move it to <code>(0,50)</code> works like a beaut! Now i want to move the button to <code>(0,100)</code> and i expect it to animate from <code>(0,50)</code> to <code>(0,100)</code> but what it does it animate from <code>(0,0)</code> to <code>(0,100)</code> so it ends up in the right location, but moves FROM the wrong location.</p> <p>i move the <code>UIButton</code> by setting a a new frame in a animation block</p> <pre><code>[UIView animateWithDuration:0.5f delay:0.0f options:UIViewAnimationCurveLinear animations:^{ } completion:nil]; </code></pre> <p>in my case i move the button in a completion block when other controls a finished moving.</p> <p>i really hope somebody out there knows exatly what im talking about and have the answer for me.</p> <p>the code i use for animating the uibutton is this, the buttons name is "btnAddPhoneNumber" and its also the "sender"</p> <pre><code>[UIView animateWithDuration:1 delay:0 options:UIViewAnimationCurveLinear animations:^{ txtNewPhoneNumber.frame = CGRectMake(newXnumber, newYnumber, txtPhoneNumber.frame.size.width, txtPhoneNumber.frame.size.height); } completion:^(BOOL finished) { txtNewPhoneNumber.placeholder = @"here you go!"; //animate add textfield button. [UIView animateWithDuration:0.5f delay:0 options:UIViewAnimationCurveLinear animations:^{ [sender setFrame:CGRectMake(btnAddPhoneNumber.frame.origin.x, newYnumber, btnAddPhoneNumber.frame.size.width, btnAddPhoneNumber.frame.size.height)]; txtNewPhoneNumberTitle.frame = CGRectMake(newXtitle, newYtitle, txtPhoneNumberTitle.frame.size.width, txtPhoneNumberTitle.frame.size.height); [btnDelete setFrame:btnDeleteRect]; } completion:^(BOOL finished) { }]; }]; </code></pre> <p>thank you for reading my question, and for helping me find a solution.</p> <p>EDIT (added code example)</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload