From 654dccb05a6c2f225539a0fff8e0aba2538370e5 Mon Sep 17 00:00:00 2001 From: Richie Date: Thu, 14 Aug 2014 11:19:16 +0800 Subject: [PATCH] prevent multiple Toast overlaps in ios --- src/ios/Toast+UIView.m | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/ios/Toast+UIView.m b/src/ios/Toast+UIView.m index aaa4fcd..1c3c76a 100644 --- a/src/ios/Toast+UIView.m +++ b/src/ios/Toast+UIView.m @@ -46,6 +46,8 @@ static const BOOL CSToastHidesOnTap = YES; // excludes activity static const NSString * CSToastTimerKey = @"CSToastTimerKey"; static const NSString * CSToastActivityViewKey = @"CSToastActivityViewKey"; +static UIView *prevToast = NULL; + @interface UIView (ToastPrivate) - (void)hideToast:(UIView *)toast; @@ -91,6 +93,10 @@ static const NSString * CSToastActivityViewKey = @"CSToastActivityViewKey"; } - (void)showToast:(UIView *)toast duration:(NSTimeInterval)duration position:(id)point { + if(prevToast){ + [self hideToast:prevToast]; + } + prevToast = toast; toast.center = [self centerPointForPosition:point withToast:toast]; toast.alpha = 0.0;