some times crashed when dismiss
adad184 opened this issue · comments
Ralph Li commented
- (void)fadeViewOut:(UIView*)popupView sourceView:(UIView*)sourceView overlayView:(UIView*)overlayView
{
[UIView animateWithDuration:kPopupModalAnimationDuration animations:^{
[self.mj_popupViewController viewWillDisappear:NO];
self.mj_popupBackgroundView.alpha = 0.0f;
popupView.alpha = 0.0f;
} completion:^(BOOL finished) {
[popupView removeFromSuperview];
[overlayView removeFromSuperview];
[self.mj_popupViewController viewDidDisappear:NO];
self.mj_popupViewController = nil;
}];
}
it shows on line
[popupView removeFromSuperview];
it happens occasionally :(
Ralph Li commented
the problem may be here
- (void)dismissPopupViewControllerWithanimationType:(MJPopupViewAnimation)animationType
{
UIView *sourceView = [self topView];
UIView *popupView = [sourceView viewWithTag:kMJPopupViewTag];
UIView *overlayView = [sourceView viewWithTag:kMJOverlayViewTag];
switch (animationType) {
case MJPopupViewAnimationSlideBottomTop:
case MJPopupViewAnimationSlideBottomBottom:
case MJPopupViewAnimationSlideTopTop:
case MJPopupViewAnimationSlideTopBottom:
case MJPopupViewAnimationSlideLeftLeft:
case MJPopupViewAnimationSlideLeftRight:
case MJPopupViewAnimationSlideRightLeft:
case MJPopupViewAnimationSlideRightRight:
[self slideViewOut:popupView sourceView:sourceView overlayView:overlayView withAnimationType:animationType];
break;
default:
[self fadeViewOut:popupView sourceView:sourceView overlayView:overlayView];
break;
}
// self.mj_popupViewController = nil;
}
the last line, self.mj_popupViewController may be released before animation is done?
Vitaly Samoylik commented
Looks like you're right. This line isn't necessary, because self.mj_popupViewController is set to nil after animation finished. And removing of this line solves the problem.