开发者

Unable to add header and footer for a table view controller

开发者 https://www.devze.com 2023-03-01 07:04 出处:网络
@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 *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
{
}
0

精彩评论

暂无评论...
验证码 换一张
取 消