Unable to add header and footer for a table view controller
@property(nonatomic,retain) UIView *tableHeaderView;
// accessory view f开发者_运维知识库or above row content. default is nil. not to be confused with section header
@property(nonatomic,retain) UIView *tableFooterView;
// accessory view below content. default is nil. not to be confused with section footer
I have added a label in footer View do inner coding according to your requirements No need to make any global variables.
- (UIView *)tableView:(UITableView *)tbleView viewForFooterInSection:(NSInteger)section
{
UILabel *label;
label = [[[UILabel alloc] initWithFrame:CGRectMake(10, 0, 300, 30)]autorelease];
[label setBackgroundColor:[UIColor clearColor]];
label.textAlignment = UITextAlignmentCenter;
[label setTextColor:[UIColor whiteColor]];
[label setFont:[UIFont boldSystemFontOfSize:15.0]];
[label setText:NSLocalizedString(@"Instructions Personal Profile",@"Instructions Personal Profile")];
UIView *view = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 30)]autorelease];
[view setAutoresizingMask:UIViewAutoresizingFlexibleWidth];
[view addSubview:label];
return view;
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
}
For setting the height of footer and header use:-
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
}
精彩评论