From b1a8c73126a7823e30c8c8cfaa950e92cc74ffde Mon Sep 17 00:00:00 2001 From: Xu Zhe Date: Tue, 6 Dec 2011 18:21:24 +0900 Subject: [PATCH 1/5] Layout all Cells after HeaderView's height changed --- Classes/AQGridView.m | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Classes/AQGridView.m b/Classes/AQGridView.m index 7ca3834..5706ea9 100755 --- a/Classes/AQGridView.m +++ b/Classes/AQGridView.m @@ -654,6 +654,15 @@ - (void) layoutSubviews if ( (_flags.needsReload == 1) && (_animationCount == 0) && (_reloadingSuspendedCount == 0) ) [self reloadData]; + if (_headerView) + { + if (_gridData.topPadding != _headerView.frame.size.height) + { + _flags.allCellsNeedLayout = 1; + _gridData.topPadding = _headerView.frame.size.height; + } + } + if ( (_reloadingSuspendedCount == 0) && (!CGRectIsEmpty([self gridViewVisibleBounds])) ) { [self updateVisibleGridCellsNow]; From 6f6ac8d83fd48d39e8408ff28b2fb93677fd68d1 Mon Sep 17 00:00:00 2001 From: Xu Zhe Date: Thu, 8 Dec 2011 01:05:23 +0900 Subject: [PATCH 2/5] the contentSize should also be changed after or 's height has been changed --- Classes/AQGridView.m | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/Classes/AQGridView.m b/Classes/AQGridView.m index 5706ea9..48dcdd8 100755 --- a/Classes/AQGridView.m +++ b/Classes/AQGridView.m @@ -89,6 +89,7 @@ - (void) deleteVisibleCell: (AQGridViewCell *) cell atIndex: (NSUInteger) visibl @interface AQGridView () @property (nonatomic, copy) NSIndexSet * animatingIndices; - (void) cellUpdateAnimationStopped: (NSString *) animationID finished: (BOOL) finished context: (void *) context; +- (void) handleGridViewBoundsChanged: (CGRect) oldBounds toNewBounds: (CGRect) bounds; @end @@ -357,6 +358,9 @@ - (void) setGridHeaderView: (UIView *) newHeaderView [_headerView removeFromSuperview]; _headerView = newHeaderView; + + CGFloat oldHeight = _gridData.topPadding; + if ( _headerView == nil ) { _gridData.topPadding = 0.0; @@ -367,6 +371,10 @@ - (void) setGridHeaderView: (UIView *) newHeaderView _gridData.topPadding = _headerView.frame.size.height; } + if ( _gridData.topPadding != oldHeight ) + { + [self handleGridViewBoundsChanged:self.bounds toNewBounds:self.bounds]; + } [self setNeedsLayout]; } @@ -383,6 +391,8 @@ - (void) setGridFooterView: (UIView *) newFooterView [_footerView removeFromSuperview]; _footerView = newFooterView; + + CGFloat oldHeight = _gridData.bottomPadding; if ( _footerView == nil ) { _gridData.bottomPadding = 0.0; @@ -393,6 +403,9 @@ - (void) setGridFooterView: (UIView *) newFooterView _gridData.bottomPadding = _footerView.frame.size.height; } + if ( _gridData.bottomPadding != oldHeight ) { + [self handleGridViewBoundsChanged:self.bounds toNewBounds:self.bounds]; + } [self setNeedsLayout]; } @@ -654,13 +667,12 @@ - (void) layoutSubviews if ( (_flags.needsReload == 1) && (_animationCount == 0) && (_reloadingSuspendedCount == 0) ) [self reloadData]; - if (_headerView) + if ( (_headerView && _gridData.topPadding != _headerView.frame.size.height ) || + (_footerView && _gridData.bottomPadding != _footerView.frame.size.height) ) { - if (_gridData.topPadding != _headerView.frame.size.height) - { - _flags.allCellsNeedLayout = 1; - _gridData.topPadding = _headerView.frame.size.height; - } + _gridData.topPadding = _headerView.frame.size.height; + _gridData.bottomPadding = _footerView.frame.size.height; + [self handleGridViewBoundsChanged:self.bounds toNewBounds:self.bounds]; } if ( (_reloadingSuspendedCount == 0) && (!CGRectIsEmpty([self gridViewVisibleBounds])) ) From 421c83da0fa12a809ec148846cd461f902b91272 Mon Sep 17 00:00:00 2001 From: Xu Zhe Date: Fri, 9 Dec 2011 16:20:13 +0900 Subject: [PATCH 3/5] update project settings for iOS archive & submit --- AQGridView.xcodeproj/project.pbxproj | 2 ++ 1 file changed, 2 insertions(+) diff --git a/AQGridView.xcodeproj/project.pbxproj b/AQGridView.xcodeproj/project.pbxproj index 7fc5000..f781246 100644 --- a/AQGridView.xcodeproj/project.pbxproj +++ b/AQGridView.xcodeproj/project.pbxproj @@ -328,6 +328,7 @@ OTHER_LDFLAGS = "-ObjC"; PREBINDING = NO; SDKROOT = iphoneos; + SKIP_INSTALL = YES; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Debug; @@ -343,6 +344,7 @@ OTHER_LDFLAGS = "-ObjC"; PREBINDING = NO; SDKROOT = iphoneos; + SKIP_INSTALL = YES; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Release; From b02fafc8f749b836d55c0c3d55316fcd0b2b220a Mon Sep 17 00:00:00 2001 From: Xu Zhe Date: Sun, 5 Feb 2012 16:46:47 +0900 Subject: [PATCH 4/5] fixed a crash problem when catched a exception --- .../project.xcworkspace/contents.xcworkspacedata | 12 ++---------- Classes/AQGridView.m | 3 ++- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/AQGridView.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/AQGridView.xcodeproj/project.xcworkspace/contents.xcworkspacedata index 57294f7..02ba8a1 100644 --- a/AQGridView.xcodeproj/project.xcworkspace/contents.xcworkspacedata +++ b/AQGridView.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -1,15 +1,7 @@ - + - - - - - - diff --git a/Classes/AQGridView.m b/Classes/AQGridView.m index 200a2c6..68746b3 100755 --- a/Classes/AQGridView.m +++ b/Classes/AQGridView.m @@ -1736,8 +1736,9 @@ - (void) updateVisibleGridCellsNow [self layoutAllCells]; } } - @catch (id exception) + @catch (__unsafe_unretained NSException *exception) { + // do nothing } @finally { From 4af6ae017c099538ac9f1f8929e2f8e384c15eed Mon Sep 17 00:00:00 2001 From: Xu Zhe Date: Sun, 5 Feb 2012 16:53:13 +0900 Subject: [PATCH 5/5] fix a overrelease problem at @catch (id exception) --- Classes/AQGridView.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Classes/AQGridView.m b/Classes/AQGridView.m index 68746b3..fca3a66 100755 --- a/Classes/AQGridView.m +++ b/Classes/AQGridView.m @@ -1736,7 +1736,7 @@ - (void) updateVisibleGridCellsNow [self layoutAllCells]; } } - @catch (__unsafe_unretained NSException *exception) + @catch (__autoreleasing NSException *exception) { // do nothing }