繁体   English   中英

使用“ UIView animateWithDuration:…”时遇到麻烦

[英]a trouble in using “UIView animateWithDuration:…”

我在动画方面遇到麻烦。 这是一些代码:

//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];
}

我想要的是“ _isEdit == YES;”时 细胞摇晃。

但是,如果在单元格摆动时我推到另一个ViewController,则将其关闭。 动画停止(“ _isEdit”仍然为“ YES”)...

如何保持动画正常工作?

如果我正确理解了这个问题,则可以在viewDidAppear中再次调用该方法,它应该重新开始。

- (void)viewDidAppear:(BOOL)animated;

如果代码来自:

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

那么您可以尝试通过在viewDidAppear方法中的tableView上调用reloadData来重新加载tableView。 如果_isEdit仍等于YES,则动画应再次触发。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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