How can I add a section heade开发者_开发百科r in UITableView?
if you just want section header title, you can use UITableViewDataSource method:
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
Or you can set you custom view as header using UITableViewDelegate method:
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
The controller implementing these, needs to be the delegate/datasource of your table view.
After using UITableViewDelegate method:
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
you must also using UITableViewDelegate method:
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section;
to display the header.
精彩评论