Skip to content
Browse files

Fixing -indexesOfSectionsInRect: and adding -rectForSection: in TUITa…

…bleView
  • Loading branch information...
1 parent 02bc7df commit 5799afe2f1186d6d1ff05ee3e3de8a3ce156adaa Brian William Wolter committed
Showing with 14 additions and 1 deletion.
  1. +1 −0 lib/UIKit/TUITableView.h
  2. +13 −1 lib/UIKit/TUITableView.m
View
1 lib/UIKit/TUITableView.h
@@ -97,6 +97,7 @@ typedef enum {
- (NSInteger)numberOfRowsInSection:(NSInteger)section;
- (CGRect)rectForHeaderOfSection:(NSInteger)section;
+- (CGRect)rectForSection:(NSInteger)section;
- (CGRect)rectForRowAtIndexPath:(TUIFastIndexPath *)indexPath;
- (NSIndexSet *)indexesOfSectionsInRect:(CGRect)rect;
View
14 lib/UIKit/TUITableView.m
@@ -228,6 +228,18 @@ - (CGRect)rectForHeaderOfSection:(NSInteger)section {
return CGRectZero;
}
+- (CGRect)rectForSection:(NSInteger)section
+{
+ if(section >= 0 && section < [_sectionInfo count]){
+ TUITableViewSection *s = [_sectionInfo objectAtIndex:section];
+ CGFloat offset = [s sectionOffset];
+ CGFloat height = [s sectionHeight];
+ CGFloat y = _contentHeight - offset - height;
+ return CGRectMake(0, y, self.bounds.size.width, height);
+ }
+ return CGRectZero;
+}
+
- (CGRect)rectForRowAtIndexPath:(TUIFastIndexPath *)indexPath
{
NSInteger section = indexPath.section;
@@ -357,7 +369,7 @@ - (NSIndexSet *)indexesOfSectionsInRect:(CGRect)rect
NSMutableIndexSet *indexes = [[NSMutableIndexSet alloc] init];
for(int i = 0; i < [_sectionInfo count]; i++) {
- if(CGRectIntersectsRect([self rectForHeaderOfSection:i], rect)){
+ if(CGRectIntersectsRect([self rectForSection:i], rect)){
[indexes addIndex:i];
}
}

0 comments on commit 5799afe

Please sign in to comment.
Something went wrong with that request. Please try again.