UILabel in header of UITableView in objective c

空扰寡人 提交于 2019-12-06 07:59:01

There is a delegate method of UITableView for custom view of Header

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section 
{
     UIView *headerView = [[UIView alloc] initWithFrame:CGRectMake(0,0,320,40)];

     UILabel *objLabel = [[UILabel alloc] initWiThFrame:CGRectMake(0,0,320,40)];
     objLabel.text = @"Post";
     [headerView addSubview:objLabel];   //Similarly You can Add any UI Component on header
     [objLabel release];

     return [headerView autorelease];
}
Basheer

If you want to show the Company, Current, prev next as text in section title, then just append the text in a single string and return this value in the following delegate method.

(NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section;

Hope this helps.

you can implement - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section and you can return what ever view you wanted for each header

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!