File tree Expand file tree Collapse file tree 3 files changed +27
-30
lines changed Expand file tree Collapse file tree 3 files changed +27
-30
lines changed Original file line number Diff line number Diff line change @@ -196,17 +196,30 @@ - (void)showFromWindow:(BOOL)animated {
196
196
}
197
197
198
198
- (void )hideFromWindow : (BOOL )animated {
199
+ [self hideFromWindow: animated withCompletion: nil ];
200
+ }
201
+
202
+ - (void )hideFromWindow : (BOOL )animated withCompletion : (void (^)(void ))completion {
203
+ __weak typeof (self) weakSelf = self;
199
204
void (^completionBlock)(void ) = ^ {
200
- [self .window removeFromSuperview ];
201
- self.window = nil ;
202
- if (self.delegate && [self .delegate respondsToSelector: @selector (notificationDidDismiss:fromViewController: )]) {
203
- [self .delegate notificationDidDismiss: self .notification fromViewController: self ];
205
+ if (!weakSelf) {
206
+ return ;
207
+ }
208
+ if (weakSelf.window ) {
209
+ [weakSelf.window removeFromSuperview ];
210
+ weakSelf.window = nil ;
211
+ }
212
+ if (weakSelf.delegate && [weakSelf.delegate respondsToSelector: @selector (notificationDidDismiss:fromViewController: )]) {
213
+ [weakSelf.delegate notificationDidDismiss: weakSelf.notification fromViewController: weakSelf];
214
+ }
215
+ if (completion) {
216
+ completion ();
204
217
}
205
218
};
206
219
207
220
if (animated) {
208
221
[UIView animateWithDuration: 0.25 animations: ^{
209
- self .window .alpha = 0 ;
222
+ weakSelf .window .alpha = 0 ;
210
223
} completion: ^(BOOL finished) {
211
224
completionBlock ();
212
225
}];
@@ -216,7 +229,6 @@ - (void)hideFromWindow:(BOOL)animated {
216
229
}
217
230
}
218
231
219
-
220
232
#pragma mark - CTInAppPassThroughViewDelegate
221
233
222
234
- (void )viewWillPassThroughTouch {
Original file line number Diff line number Diff line change 22
22
23
23
- (void )showFromWindow : (BOOL )animated ;
24
24
- (void )hideFromWindow : (BOOL )animated ;
25
+ - (void )hideFromWindow : (BOOL )animated withCompletion : (void (^)(void ))completion ;
25
26
26
27
- (void )tappedDismiss ;
27
28
- (void )buttonTapped : (UIButton*)button ;
Original file line number Diff line number Diff line change @@ -510,29 +510,6 @@ - (void)showFromWindow:(BOOL)animated {
510
510
}
511
511
}
512
512
513
- - (void )hideFromWindow : (BOOL )animated {
514
- void (^completionBlock)(void ) = ^ {
515
- [self ->webView.configuration.userContentController removeScriptMessageHandlerForName: @" clevertap" ];
516
- [self .window removeFromSuperview ];
517
- self.window = nil ;
518
- if (self.delegate && [self .delegate respondsToSelector: @selector (notificationDidDismiss:fromViewController: )]) {
519
- [self .delegate notificationDidDismiss: self .notification fromViewController: self ];
520
- }
521
- };
522
-
523
- if (animated) {
524
- [UIView animateWithDuration: 0.25 animations: ^{
525
- self.window .alpha = 0 ;
526
- } completion: ^(BOOL finished) {
527
- completionBlock ();
528
- }];
529
- }
530
- else {
531
- completionBlock ();
532
- }
533
- }
534
-
535
-
536
513
#pragma mark - Public
537
514
538
515
- (void )show : (BOOL )animated {
@@ -541,7 +518,14 @@ - (void)show:(BOOL)animated {
541
518
}
542
519
543
520
- (void )hide : (BOOL )animated {
544
- [self hideFromWindow: animated];
521
+ __weak typeof (self) weakSelf = self;
522
+ [self hideFromWindow: animated withCompletion: ^{
523
+ __strong typeof (weakSelf) strongSelf = weakSelf;
524
+ if (!strongSelf) {
525
+ return ;
526
+ }
527
+ [strongSelf->webView.configuration.userContentController removeScriptMessageHandlerForName: @" clevertap" ];
528
+ }];
545
529
}
546
530
547
531
@end
You can’t perform that action at this time.
0 commit comments