Animatewithduration of the iOS pit

Source: Internet
Author: User

[UIView animatewithduration:<# (Nstimeinterval) #> delay:<# (nstimeinterval) #> options:<# ( uiviewanimationoptions) #> animations:<#^ (void) animations#> completion:<#^ (BOOL finished) completion# >

This function first requires that the animations animation settings be performed immediately by the function call, while the delay time is performed completion. Here's a pit where if you want to click on a control that is performing a uiview animation, for example, to change the position of X, Y, even if we search the Web for a configuredUIViewAnimationOptionAllowUserInteraction也是不行触发点击,原因就是控件首先执行了animations动画,x,y轴已经改变。


Workaround one: Overwrite an animation, set to Alpha 0.99, and trigger your event by this control

Solution Two (recommended): Use real delay dispatch_after

1 dispatch_after (Poptime, Dispatch_get_main_queue (), ^ (void) {2         [UIView animatewithduration:0.5 animations:^{3             //  moving animation 4         } completion:^(BOOL finished) {5             //  animation completed settings 6         }]; 7     });

Animatewithduration of the iOS pit

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.