Skip to content
This repository has been archived by the owner on Jun 3, 2021. It is now read-only.

Commit

Permalink
[iOS] Fix problem that toasts of last deallocated page continue to sh…
Browse files Browse the repository at this point in the history
…ow in later pages. (#2106)
  • Loading branch information
wqyfavor authored and doumafang committed Feb 12, 2019
1 parent fa814af commit 2d9eeb9
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions ios/sdk/WeexSDK/Sources/Module/WXModalUIModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ @interface WXToastInfo : NSObject

@property (nonatomic, strong) UIView *toastView;
@property (nonatomic, weak) UIView *superView;
@property (nonatomic, weak) WXSDKInstance *instance;
@property (nonatomic, assign) double duration;

@end
Expand Down Expand Up @@ -135,6 +136,7 @@ - (void)toast:(NSString *)message duration:(double)duration
}
UIView *toastView = [self toastViewForMessage:message superView:superView];
WXToastInfo *info = [WXToastInfo new];
info.instance = self.weexInstance;
info.toastView = toastView;
info.superView = superView;
info.duration = duration;
Expand Down Expand Up @@ -228,6 +230,15 @@ - (void)showToast:(UIView *)toastView superView:(UIView *)superView duration:(do
NSMutableArray *queue = [WXToastManager sharedManager].toastQueue;
if (queue.count > 0) {
[queue removeObjectAtIndex:0];

// remove invalid toasts
for (NSInteger i = [queue count] - 1; i >= 0; i --) {
WXToastInfo *info = queue[i];
if (info.instance == nil) {
[queue removeObjectAtIndex:i];
}
}

if (queue.count > 0) {
WXToastInfo *info = [queue firstObject];
[weakSelf showToast:info.toastView superView:info.superView duration:info.duration];
Expand Down

0 comments on commit 2d9eeb9

Please sign in to comment.