From 3f3b8efb04bc03fe01bcd89b453ab95102e1690e Mon Sep 17 00:00:00 2001 From: Grigory Lutkov Date: Fri, 13 Nov 2015 16:52:12 +0300 Subject: [PATCH] Add class method to get all existings LGAlertViews --- .../LGAlertViewDemo.xcodeproj/project.pbxproj | 4 +-- LGAlertView.podspec | 2 +- LGAlertView/LGAlertView.h | 4 +++ LGAlertView/LGAlertView.m | 28 ++++++++++++++++++- 4 files changed, 34 insertions(+), 4 deletions(-) diff --git a/Demo/LGAlertViewDemo.xcodeproj/project.pbxproj b/Demo/LGAlertViewDemo.xcodeproj/project.pbxproj index 702d1dc..1b68759 100644 --- a/Demo/LGAlertViewDemo.xcodeproj/project.pbxproj +++ b/Demo/LGAlertViewDemo.xcodeproj/project.pbxproj @@ -334,7 +334,7 @@ INFOPLIST_FILE = LGAlertViewDemo/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 6.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = "com.test.$(PRODUCT_NAME)"; + PRODUCT_BUNDLE_IDENTIFIER = "com.test.LGAlertViewDemo-"; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE = ""; }; @@ -350,7 +350,7 @@ INFOPLIST_FILE = LGAlertViewDemo/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 6.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = "com.test.$(PRODUCT_NAME)"; + PRODUCT_BUNDLE_IDENTIFIER = "com.test.LGAlertViewDemo-"; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE = ""; }; diff --git a/LGAlertView.podspec b/LGAlertView.podspec index e84fad0..c525e15 100644 --- a/LGAlertView.podspec +++ b/LGAlertView.podspec @@ -1,7 +1,7 @@ Pod::Spec.new do |s| s.name = 'LGAlertView' - s.version = '2.0.7' + s.version = '2.0.8' s.platform = :ios, '6.0' s.license = 'MIT' s.homepage = 'https://github.com/Friend-LGA/LGAlertView' diff --git a/LGAlertView/LGAlertView.h b/LGAlertView/LGAlertView.h index 57f3484..d59365e 100644 --- a/LGAlertView/LGAlertView.h +++ b/LGAlertView/LGAlertView.h @@ -494,8 +494,12 @@ typedef NS_ENUM(NSUInteger, LGAlertViewWindowLevel) - (void)forceDestructive; - (void)forceActionAtIndex:(NSUInteger)index; +/** Set tint color globally for all LGAlertViews */ + (void)setTintColor:(UIColor *)color; +/** Set colorful globally for all LGAlertViews */ + (void)setColorful:(BOOL)colorful; +/** Get array of all existings LGAlertViews */ ++ (NSArray *)getAlertViewsArray; #pragma mark - diff --git a/LGAlertView/LGAlertView.m b/LGAlertView/LGAlertView.m index 26bd2e2..747d630 100644 --- a/LGAlertView/LGAlertView.m +++ b/LGAlertView/LGAlertView.m @@ -52,6 +52,7 @@ static NSMutableArray *kLGAlertViewWindowsArray; static UIColor *kLGAlertViewTintColor; static BOOL kLGAlertViewColorful = YES; +static NSMutableArray *kLGAlertViewArray; #pragma mark - Interface @@ -823,6 +824,9 @@ - (void)setupDefaults if (!kLGAlertViewWindowsArray) kLGAlertViewWindowsArray = [NSMutableArray new]; + if (!kLGAlertViewArray) + kLGAlertViewArray = [NSMutableArray new]; + // ----- _buttonsEnabledArray = [NSMutableArray new]; @@ -1271,6 +1275,13 @@ - (void)setProgressViewProgressTintColor:(UIColor *)progressViewProgressTintColo _userProgressViewProgressTintColor = YES; } +- (BOOL)isShowing +{ + return (_showing && _window.isKeyWindow && !_window.isHidden); +} + +#pragma mark - Class methods + + (void)setTintColor:(UIColor *)color { kLGAlertViewTintColor = color; @@ -1281,6 +1292,14 @@ + (void)setColorful:(BOOL)colorful kLGAlertViewColorful = colorful; } ++ (NSArray *)getAlertViewsArray +{ + if (!kLGAlertViewArray) + kLGAlertViewArray = [NSMutableArray new]; + + return kLGAlertViewArray; +} + #pragma mark - - (void)setProgress:(float)progress progressLabelText:(NSString *)progressLabelText @@ -1587,6 +1606,9 @@ - (void)showAnimated:(BOOL)animated hidden:(BOOL)hidden completionHandler:(void( _showing = YES; + if (![kLGAlertViewArray containsObject:self]) + [kLGAlertViewArray addObject:self]; + // ----- [self addObservers]; @@ -1809,7 +1831,11 @@ - (void)dismissComplete // ----- - [kLGAlertViewWindowsArray removeObject:_window]; + if ([kLGAlertViewWindowsArray containsObject:_window]) + [kLGAlertViewWindowsArray removeObject:_window]; + + if ([kLGAlertViewArray containsObject:self]) + [kLGAlertViewArray removeObject:self]; _view = nil; _viewController = nil;