Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

using completion with animateWithDuration causes exc_bad_access

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.

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

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.

Thanks

like image 876
craigk Avatar asked May 11 '11 00:05

craigk


1 Answers

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

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

like image 89
ivanzoid Avatar answered Nov 13 '22 04:11

ivanzoid