开发者

How to add description to the UITableView

How c开发者_如何学运维an I to add a description like "California" in this image.


- (NSInteger)numberOfSections
{
   return 1;
}

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


Its your table header. The table view header for sections. You can have section headers by implementing the datasource method

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


In your UITableViewDataSource (a delegate of the UITableView),

this method controls the section header titles:

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


That is a section header.The UITableViewDelegate Method is:

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


- (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;
}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜