2011-05-20 97 views

回答

3
- (NSInteger)numberOfSections 
{ 
    return 1; 
} 

- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section 
{ 
    if (section == 0) 
     return @"California"; 
    return nil; 
} 
0

这是一款header.The 的UITableViewDelegate方法是:

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section 
1

,是你的表头。部分的表格视图标题。您可以通过实现数据源方法

- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section 
1

在你UITableViewDataSource(中的UITableView的委托)有节标题,

这种方法控制节标题标题:

- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section 
0
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section 
{ 
UIView * view = [uiview alloc]initWithFrame:CGRectMake(0, 0, tableView.frame.size.width, 90)]; 
then Create UIView in UILable ,UItextView etc... 
} 
then 
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section 
{ 
return 50; 
}