我正在制作一个 iPad 应用程序,其中有一个分组的 TableView,其中包含各部分的标题。
我想在tableview的标题中添加四个标签
四个标签的文本分别是“company”、“current”、“prev close”、“change”
或
我不想在标题中添加四个标签,而是想添加四个文本“company”、“current”、“prev close”、“change”
我应该做什么?
请提供帮助和建议。
谢谢。
最佳答案
UITableView有一个委托(delegate)方法,用于自定义Header View
- (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];
}
关于iphone - Objective C 中 UITableView 标题中的 UILabel,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8485536/