使用animateWithDuration完成导致exc_bad_access [英] using completion with animateWithDuration causes exc_bad_access

查看:147
本文介绍了使用animateWithDuration完成导致exc_bad_access的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在名为addToPlaylist和removeFromPlayList的UITableViewCell中设置2个UIButtons(在刷卡后将它们设置为向右动画)并使用如下块:

I am trying to animate 2 UIButtons in a UITableViewCell called addToPlaylist and removeFromPlayList (they animate off to the right after being swiped on) and am using a block as follows

[UIView animateWithDuration:0.25 animations:^{

    self.addToPlaylist.center      = CGPointMake(contentsSize.width + (buttonSize.width / 2), (buttonSize.height / 2));
    self.removeFromPlaylist.center = CGPointMake(contentsSize.width + (buttonSize.width / 2), (buttonSize.height / 2));
    myImage.alpha = 1.0;

}
 completion:^ (BOOL finished) 
 {
     if (finished) {
         // Revert image view to original.
         NSLog(@"Is completed");
         self.addToPlaylist.hidden       = YES;
         self.removeFromPlaylist.hidden  = YES;
         self.hasSwipeOpen               = NO;
     }
 }];

完成后我想隐藏按钮以尝试减少滚动时的重绘等。

on completion I want to hide the buttons to attempt to lessen redraw on scroll etc.

此代码位于' - (void)swipeOff'中,在UITableViewControllers方法中调用scrollViewWillBeginDragging,如下所示:

This code sits within '-(void) swipeOff' which is called in the UITableViewControllers method scrollViewWillBeginDragging like so:

- (void)scrollViewWillBeginDragging:(UIScrollView *) scrollView
{
   for (MediaCellView* cell in [self.tableView visibleCells]) {
        if (cell.hasSwipeOpen) {
           [cell swipeOff];
        }
    }
}

问题是完成代码,如果我删除它或将其设置为nil一切都很好,如果我包含它我得到一个EXC_BAD_ACCESS。即使我在if(已完成)注释掉的任何或所有行中包含它

The problem is the completion code, if I remove it or set it to nil all is good, if I include it I get an EXC_BAD_ACCESS. even if I include it with any or all of the lines within the if(finished) commented out

我是否以错误的方式使用它,任何帮助都非常感激。

Am I using this in the wrong way, any help much appreciated.

谢谢

推荐答案

我的动画遇到了同样的问题。我已经通过从其他链接器标志中删除 -weak_library /usr/lib/libSystem.B.dylib 来解决它。

I had the same problem with animations. I've solved it by removing -weak_library /usr/lib/libSystem.B.dylib from Other Linker flags.

另外,根据这个答案,如果你需要这个标志,你可以用 -weak-lSystem 替换它。

Also, according to this answer, if you need this flag, you may replace it with -weak-lSystem.

这篇关于使用animateWithDuration完成导致exc_bad_access的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆