Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
511 views
in Technique[技术] by (71.8m points)

iphone - 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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...