Skip to content
This repository has been archived by the owner on May 8, 2020. It is now read-only.

Commit

Permalink
Merge branch 'feature/GH1' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
danielctull committed Oct 24, 2010
2 parents 5afda2b + 6ebd425 commit e972012
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 4 deletions.
2 changes: 1 addition & 1 deletion DTGridView.xcodeproj/project.pbxproj
Expand Up @@ -319,7 +319,7 @@
GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES; GCC_WARN_UNUSED_VARIABLE = YES;
PREBINDING = NO; PREBINDING = NO;
SDKROOT = iphoneos; SDKROOT = iphoneos3.2;
}; };
name = Debug; name = Debug;
}; };
Expand Down
31 changes: 28 additions & 3 deletions DTGridView/DTGridView.m
Expand Up @@ -200,6 +200,19 @@ - (void)addCellWithInfo:(NSObject<DTGridViewCellInfoProtocol> *)info {
[[gridCells objectAtIndex:info.yPosition] replaceObjectAtIndex:info.xPosition withObject:cell]; [[gridCells objectAtIndex:info.yPosition] replaceObjectAtIndex:info.xPosition withObject:cell];


[self insertSubview:cell atIndex:0]; [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]; [cell release];


} }
Expand Down Expand Up @@ -286,8 +299,8 @@ - (void)loadData {


NSMutableArray *cellInfoArrayRows = [[NSMutableArray alloc] init]; NSMutableArray *cellInfoArrayRows = [[NSMutableArray alloc] init];


CGFloat maxHeight; CGFloat maxHeight = 0;
CGFloat maxWidth; CGFloat maxWidth = 0;




for (NSInteger i = 0; i < self.numberOfRows; i++) { for (NSInteger i = 0; i < self.numberOfRows; i++) {
Expand Down Expand Up @@ -356,6 +369,18 @@ - (void)loadData {
self.gridCells = cellInfoArrayRows; self.gridCells = cellInfoArrayRows;
[cellInfoArrayRows release]; [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 { - (void)checkViews {
Expand Down Expand Up @@ -574,7 +599,7 @@ - (DTGridViewCell *)cellForRow:(NSInteger)rowIndex column:(NSInteger)columnIndex


- (void)scrollViewToRow:(NSInteger)rowIndex column:(NSInteger)columnIndex scrollPosition:(DTGridViewScrollPosition)position animated:(BOOL)animated { - (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]; CGRect cellFrame = [[[self.gridCells objectAtIndex:rowIndex] objectAtIndex:columnIndex] frame];


Expand Down

0 comments on commit e972012

Please sign in to comment.