@@ -770,8 +770,15 @@ - (void)closePopupWithAnimation:(BOOL)animated
770770 LPActionContext *context = _contexts.lastObject ;
771771 [_contexts removeLastObject ];
772772
773+ if ([[context actionName ] isEqualToString: LPMT_WEB_INTERSTITIAL_NAME] ||
774+ [[context actionName ] isEqualToString: LPMT_HTML_NAME] ) {
775+ ((UIWebView *)_popupView).delegate = nil ;
776+ [(UIWebView *)_popupView stopLoading ];
777+ }
778+
773779 void (^finishCallback)(void ) = ^() {
774- [self ->_popupGroup removeFromSuperview ];
780+ [self removeAllViewsFrom: _popupGroup];
781+
775782 if (actionName) {
776783 if (track) {
777784 [context runTrackedActionNamed: actionName];
@@ -791,28 +798,20 @@ - (void)closePopupWithAnimation:(BOOL)animated
791798 finishCallback ();
792799 }
793800
794- if ([[context actionName ] isEqualToString: LPMT_WEB_INTERSTITIAL_NAME] ||
795- [[context actionName ] isEqualToString: LPMT_HTML_NAME] ) {
796- ((UIWebView *)_popupView).delegate = nil ;
797- [(UIWebView *)_popupView stopLoading ];
798- }
799-
800- _popupView = nil ;
801- _popupBackground = nil ;
802- _acceptButton = nil ;
803- _cancelButton = nil ;
804- _titleLabel = nil ;
805- _messageLabel = nil ;
806- _popupGroup = nil ;
807- _dismissButton = nil ;
808- _overlayView = nil ;
809- _closePopupView = nil ;
810-
811801 [[NSNotificationCenter defaultCenter ] removeObserver: self
812802 name: UIApplicationDidChangeStatusBarOrientationNotification
813803 object: nil ];
814804}
815805
806+ - (void )removeAllViewsFrom : (UIView *)view
807+ {
808+ [view.subviews enumerateObjectsUsingBlock: ^(UIView *obj, NSUInteger idx, BOOL *stop) {
809+ [self removeAllViewsFrom: obj];
810+ }];
811+ [view removeFromSuperview ];
812+ view = nil ;
813+ }
814+
816815- (void )accept
817816{
818817 [self closePopupWithAnimation: YES actionNamed: LPMT_ARG_ACCEPT_ACTION track: YES ];
0 commit comments