From ad3383c1c7e2de3cf96d4b3aa3067cedaaef27e3 Mon Sep 17 00:00:00 2001 From: Grigory Lutkov Date: Tue, 10 Nov 2015 14:49:40 +0300 Subject: [PATCH] Fixed bugs --- Demo/Podfile.lock | 4 ++-- LGAlertView.podspec | 2 +- LGAlertView/LGAlertView.m | 24 +++++++++++------------- 3 files changed, 14 insertions(+), 16 deletions(-) diff --git a/Demo/Podfile.lock b/Demo/Podfile.lock index d3756e2..c71b888 100644 --- a/Demo/Podfile.lock +++ b/Demo/Podfile.lock @@ -1,5 +1,5 @@ PODS: - - LGAlertView (2.0.4) + - LGAlertView (2.0.5) DEPENDENCIES: - LGAlertView (from `../`) @@ -9,6 +9,6 @@ EXTERNAL SOURCES: :path: ../ SPEC CHECKSUMS: - LGAlertView: bd8c89da95f31a9bdeda279d9939629cbcbfaaca + LGAlertView: dffa2d6fd7b485bb9bee0c2bff29d71b77f318cb COCOAPODS: 0.39.0 diff --git a/LGAlertView.podspec b/LGAlertView.podspec index b786f59..82d8d6e 100644 --- a/LGAlertView.podspec +++ b/LGAlertView.podspec @@ -1,7 +1,7 @@ Pod::Spec.new do |s| s.name = 'LGAlertView' - s.version = '2.0.4' + s.version = '2.0.5' s.platform = :ios, '6.0' s.license = 'MIT' s.homepage = 'https://github.com/Friend-LGA/LGAlertView' diff --git a/LGAlertView/LGAlertView.m b/LGAlertView/LGAlertView.m index 72672b0..8d3263b 100644 --- a/LGAlertView/LGAlertView.m +++ b/LGAlertView/LGAlertView.m @@ -1339,7 +1339,7 @@ - (void)setButtonAtIndex:(NSUInteger)index enabled:(BOOL)enabled - (BOOL)isButtonEnabledAtIndex:(NSUInteger)index { - return _buttonsEnabledArray[index]; + return (BOOL)_buttonsEnabledArray[index]; } - (void)setButtonPropertiesAtIndex:(NSUInteger)index @@ -1350,17 +1350,15 @@ - (void)setButtonPropertiesAtIndex:(NSUInteger)index if (!_buttonsPropertiesDictionary) _buttonsPropertiesDictionary = [NSMutableDictionary new]; - for (NSUInteger index=0; index<_buttonTitles.count; index++) - { - LGAlertViewButtonProperties *properties = [LGAlertViewButtonProperties new]; + LGAlertViewButtonProperties *properties = _buttonsPropertiesDictionary[[NSNumber numberWithInteger:index]]; + if (!properties) properties = [LGAlertViewButtonProperties new]; - handler(properties); + handler(properties); - if (properties.isUserEnabled) - _buttonsEnabledArray[index] = [NSNumber numberWithBool:properties.enabled]; + if (properties.isUserEnabled) + _buttonsEnabledArray[index] = [NSNumber numberWithBool:properties.enabled]; - [_buttonsPropertiesDictionary setObject:properties forKey:[NSNumber numberWithInteger:index]]; - } + [_buttonsPropertiesDictionary setObject:properties forKey:[NSNumber numberWithInteger:index]]; } } @@ -1459,7 +1457,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N cell.lineBreakMode = (properties.isUserLineBreakMode ? properties.lineBreakMode : _buttonsLineBreakMode); cell.adjustsFontSizeToFitWidth = (properties.isUserAdjustsFontSizeTofitWidth ? properties.adjustsFontSizeToFitWidth : _buttonsAdjustsFontSizeToFitWidth); cell.minimumScaleFactor = (properties.isUserMinimimScaleFactor ? properties.minimumScaleFactor : _buttonsMinimumScaleFactor); - cell.enabled = _buttonsEnabledArray[indexPath.row - (_destructiveButtonTitle.length ? 1 : 0)]; + cell.enabled = (BOOL)_buttonsEnabledArray[indexPath.row - (_destructiveButtonTitle.length ? 1 : 0)]; } return cell; @@ -2247,7 +2245,7 @@ - (void)subviewsInvalidateWithSize:(CGSize)size _firstButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft; else if (textAlignment == NSTextAlignmentRight) _firstButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentRight; - _firstButton.enabled = _buttonsEnabledArray[0]; + _firstButton.enabled = (BOOL)_buttonsEnabledArray[0]; [_firstButton addTarget:self action:@selector(firstButtonAction:) forControlEvents:UIControlEventTouchUpInside]; CGSize size = [_firstButton sizeThatFits:CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX)]; @@ -2286,7 +2284,7 @@ - (void)subviewsInvalidateWithSize:(CGSize)size _secondButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft; else if (textAlignment == NSTextAlignmentRight) _secondButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentRight; - _secondButton.enabled = _buttonsEnabledArray[1]; + _secondButton.enabled = (BOOL)_buttonsEnabledArray[1]; [_secondButton addTarget:self action:@selector(secondButtonAction:) forControlEvents:UIControlEventTouchUpInside]; CGSize size = [_secondButton sizeThatFits:CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX)]; @@ -2325,7 +2323,7 @@ - (void)subviewsInvalidateWithSize:(CGSize)size _thirdButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft; else if (textAlignment == NSTextAlignmentRight) _thirdButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentRight; - _thirdButton.enabled = _buttonsEnabledArray[2]; + _thirdButton.enabled = (BOOL)_buttonsEnabledArray[2]; [_thirdButton addTarget:self action:@selector(thirdButtonAction:) forControlEvents:UIControlEventTouchUpInside]; CGSize size = [_thirdButton sizeThatFits:CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX)];