Skip to content
This repository has been archived by the owner on Aug 16, 2021. It is now read-only.

Commit

Permalink
Support from footer and header views
Browse files Browse the repository at this point in the history
  • Loading branch information
rbsgn committed Jul 24, 2010
1 parent d84647e commit e8fe16e
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 1 deletion.
1 change: 1 addition & 0 deletions Classes/YXModelTableViewController.h
Expand Up @@ -9,6 +9,7 @@
#import <UIKit/UIKit.h>

@interface YXModelTableViewController : UITableViewController {
@private
NSArray * sections_;
}

Expand Down
26 changes: 26 additions & 0 deletions Classes/YXModelTableViewController.m
Expand Up @@ -58,6 +58,32 @@ - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInte
return section.header;
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)sectionIndex {
YXSection * section = [self.sections objectAtIndex:sectionIndex];
return section.headerView;
}

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)sectionIndex {
YXSection * section = [self.sections objectAtIndex:sectionIndex];
return section.footerView;
}

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)sectionIndex {
YXSection * section = [self.sections objectAtIndex:sectionIndex];
if (section.footer == nil && section.footerView != nil) {
return CGRectGetHeight(section.footerView.frame);
}
return -1.0f;
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)sectionIndex {
YXSection * section = [self.sections objectAtIndex:sectionIndex];
if (section.header == nil && section.headerView != nil) {
return CGRectGetHeight(section.headerView.frame);
}
return -1.0f;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
YXAbstractCell * cell = [self modelCellAtIndexPath:indexPath];
UITableViewCell * reusableCell = [tableView dequeueReusableCellWithIdentifier:cell.reuseIdentifier];
Expand Down
9 changes: 9 additions & 0 deletions Classes/YXSection.h
Expand Up @@ -7,18 +7,27 @@
//

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>

@class YXAbstractCell;

@interface YXSection : NSObject {
@private
NSString * header_;
NSString * footer_;

UIView * headerView_;
UIView * footerView_;

NSMutableArray * cells_;
}

@property (nonatomic, readonly) NSString * header;
@property (nonatomic, readonly) NSString * footer;

@property (nonatomic, retain) UIView *footerView;
@property (nonatomic, retain) UIView *headerView;

@property (nonatomic, readonly) NSArray * cells;

- (id)init;
Expand Down
8 changes: 7 additions & 1 deletion Classes/YXSection.m
Expand Up @@ -61,13 +61,19 @@ - (void)removeCell:(YXAbstractCell *)cell {

@synthesize header = header_;
@synthesize footer = footer_;
@synthesize headerView = headerView_;
@synthesize footerView = footerView_;


- (void)dealloc {
[cells_ release];
[header_ release];
[footer_ release];

[headerView_ release];
[footerView_ release];

[cells_ release];

[super dealloc];
}

Expand Down

0 comments on commit e8fe16e

Please sign in to comment.