iphone - Objective C 中 UITableView 标题中的 UILabel

标签 iphone ipad uitableview header uilabel

我正在制作一个 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/

相关文章:

ios - 为 iPad/iPhone 加载不同的启动屏幕

ios - 是否有必要创建一个应用程序的视网膜版本?

iphone - 如何从 uipickerview 更改颜色选择器值?

iphone - 双截面可扩展桌面 View

iphone - 在 iPhone 上使用 3G 而不是连接的 Wi-Fi

iphone - 如何手动关闭UAModalPanel

iphone - Xcode:子类化我自己的类时出现非常奇怪的错误

javascript - 移动屏幕上导航栏的奇怪行为

ios - 使用 UISearchController 的 segue 的不同行为

ios - TableView 复制上的复选框,Swift,iOS