简体   繁体   中英

a trouble in using “UIView animateWithDuration:…”

I'm having a trouble in animation. here is some codes:

//wobbling cells in collection view controller
if (_isEdit){
    myCell.transform = CGAffineTransformMakeRotation(-0.01);

    [UIView animateWithDuration:0.12
                          delay:0.0
                        options:UIViewAnimationOptionRepeat|UIViewAnimationOptionAutoreverse|UIViewAnimationOptionAllowUserInteraction|UIViewAnimationOptionCurveLinear
                     animations:^{
                         myCell.transform = CGAffineTransformMakeRotation(0.01);
                     } completion:nil];
}

What I want is when the "_isEdit == YES;" cells wobbling.

But if I push to another ViewController when the cells wobbling, then dismiss. The animation stop ("_isEdit" is still "YES")...

How can I keep the animation working?

If I understood the question correctly you can just call the method again in viewDidAppear, and it should start again.

- (void)viewDidAppear:(BOOL)animated;

If the code is from:

- (UITableViewCell *)tableView:(UITableView *)tableView 
     cellForRowAtIndexPath:(NSIndexPath *)indexPath;

then you could try just reloading the tableView by calling reloadData on the tableView in the viewDidAppear method. If the _isEdit is still equal to YES then the animation should trigger again.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM