From a4d8579d792b5c6c576ea6e30c8e65f5e48826f8 Mon Sep 17 00:00:00 2001 From: Benyang Date: Sun, 6 May 2012 18:12:58 +0800 Subject: [PATCH] Fix insertObjectAtIndex: can not increase old view's tag issue --- GMGridView/GMGridView.m | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/GMGridView/GMGridView.m b/GMGridView/GMGridView.m index c362c29..a7ae106 100644 --- a/GMGridView/GMGridView.m +++ b/GMGridView/GMGridView.m @@ -1626,12 +1626,6 @@ - (void)insertObjectAtIndex:(NSInteger)index withAnimation:(GMGridViewItemAnimat { cell = [self newItemSubViewForPosition:index]; - for (int i = _numberTotalItems - 1; i >= index; i--) - { - UIView *oldView = [self cellForItemAtIndex:i]; - oldView.tag = oldView.tag + 1; - } - if (animation & GMGridViewItemAnimationFade) { cell.alpha = 0; [UIView beginAnimations:nil context:NULL]; @@ -1642,6 +1636,12 @@ - (void)insertObjectAtIndex:(NSInteger)index withAnimation:(GMGridViewItemAnimat } [self addSubview:cell]; } + + for (int i = _numberTotalItems - 1; i >= index; i--) + { + UIView *oldView = [self cellForItemAtIndex:i]; + oldView.tag = oldView.tag + 1; + } _numberTotalItems++; [self recomputeSizeAnimated:!(animation & GMGridViewItemAnimationNone)];