2011-05-20 101 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; 
}