21

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

craigk
  • 1,294
  • 2
  • 12
  • 25
  • If you leave out the assignments and keep the NSLog, does the code work without crash? Does it always crash or just when the tableview scrolls? – Nick Weaver May 11 '11 at 06:40
  • Hi Nick, it will still crash with just the NSLog in there, and it is only when the tableView scrolls – craigk May 11 '11 at 10:14

2 Answers2

20

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.

Community
  • 1
  • 1
ivanzoid
  • 5,952
  • 2
  • 34
  • 43
  • thanks mate, I had given up on that one. I had to use the -weak-lSystem but it got rid of the crash/error. +1 for the links – craigk Jun 13 '11 at 23:48
0

Check if you are not calling a UIView (collectionView, Mapview, etc) from inside the UIView block, meaning, it would be a call outside the main thread. If you are, try this:

DispatchQueue.main.async {
self.mapBoxView.setZoomLevel(self.FLYOVERZOOMLEVEL, animated: true
)}
xskxzr
  • 12,442
  • 12
  • 37
  • 77
TDesign
  • 569
  • 4
  • 8