Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'release/1.0.1'

  • Loading branch information...
commit cb9580be610f9f28eaaef7f489246d384e2852a4 2 parents 5afda2b + e972012
@danielctull authored
Showing with 29 additions and 4 deletions.
  1. +1 −1  DTGridView.xcodeproj/project.pbxproj
  2. +28 −3 DTGridView/DTGridView.m
View
2  DTGridView.xcodeproj/project.pbxproj
@@ -319,7 +319,7 @@
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
PREBINDING = NO;
- SDKROOT = iphoneos;
+ SDKROOT = iphoneos3.2;
};
name = Debug;
};
View
31 DTGridView/DTGridView.m
@@ -200,6 +200,19 @@ - (void)addCellWithInfo:(NSObject<DTGridViewCellInfoProtocol> *)info {
[[gridCells objectAtIndex:info.yPosition] replaceObjectAtIndex:info.xPosition withObject:cell];
[self insertSubview:cell atIndex:0];
+
+ // remove any existing view at this frame
+ for (UIView *v in self.subviews) {
+ if ([v isKindOfClass:[DTGridViewCell class]] &&
+ v.frame.origin.x == cell.frame.origin.x &&
+ v.frame.origin.y == cell.frame.origin.y &&
+ v != cell) {
+
+ [v removeFromSuperview];
+ break;
+ }
+ }
+
[cell release];
}
@@ -286,8 +299,8 @@ - (void)loadData {
NSMutableArray *cellInfoArrayRows = [[NSMutableArray alloc] init];
- CGFloat maxHeight;
- CGFloat maxWidth;
+ CGFloat maxHeight = 0;
+ CGFloat maxWidth = 0;
for (NSInteger i = 0; i < self.numberOfRows; i++) {
@@ -356,6 +369,18 @@ - (void)loadData {
self.gridCells = cellInfoArrayRows;
[cellInfoArrayRows release];
+ if ([self.subviews count] > [self.gridCells count]) {
+ // the underlying data must have reduced, time to iterate
+ NSSet *gridCellsSet = [NSSet setWithArray:self.gridCells];
+ NSArray *subviewsCopy = [self.subviews copy];
+
+ for (DTGridViewCell *cell in subviewsCopy) {
+ if (![gridCellsSet member:cell])
+ [cell removeFromSuperview];
+ }
+
+ [subviewsCopy release];
+ }
}
- (void)checkViews {
@@ -574,7 +599,7 @@ - (DTGridViewCell *)cellForRow:(NSInteger)rowIndex column:(NSInteger)columnIndex
- (void)scrollViewToRow:(NSInteger)rowIndex column:(NSInteger)columnIndex scrollPosition:(DTGridViewScrollPosition)position animated:(BOOL)animated {
- CGFloat xPos, yPos;
+ CGFloat xPos = 0, yPos = 0;
CGRect cellFrame = [[[self.gridCells objectAtIndex:rowIndex] objectAtIndex:columnIndex] frame];
Please sign in to comment.
Something went wrong with that request. Please try again.