[super viewDidLoad];
self.Lodgelist = [[NSArray alloc]
initWithObjects:@"Sterling ",
@"Sterling location 1234",
@"Sterling location 12345",nil];
这是我的代码示例。我希望标题是城市名称"Sterling",我是objective-c的新手。再次感谢您的帮助。
附言我不确定如何或要添加代码。
在 ViewController 的标头中添加 UITableViewDelegate,然后添加以下代码以更改 UITableView 的标头
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
return [self.Lodgelist objectAtIndex:0];
}
如果您只想将标题设置为标题,请使用
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
return [self.Lodgelist objectAtIndex:section];
}
如果您想在部分标题(或某些视图(中添加一些图像和其他内容,请使用
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section