Я хочу изменить tableHeader
высоту, шрифт и т.д ...heightForHeaderInSection не получает вызов?
Я реализовал UITableViewDelegate
, UITableViewDataSource
и добавил heightForHeaderInSection
и viewForHeaderInSection
. Но эти два метода не вызываются. Другие методы, такие как numberOfRowsInSection
/cellForRowAtIndexPath
, работают нормально. Я могу видеть таблицу, но без заголовка :(
Любая идея
вот код:
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [self.poHeader.itemList count];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
NSLog(@"numberOfSectionsInTableView");
return 1;
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
NSLog(@"*******height");
return 44.0;
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
NSLog(@"***in viewForHeader In section");
UIView* customView = [[UIView alloc] initWithFrame:CGRectMake(2, 166, 300.0, 44.0)];
UILabel * headerLabel = [[UILabel alloc] initWithFrame:CGRectZero];
headerLabel.backgroundColor = [UIColor clearColor];
headerLabel.opaque = NO;
headerLabel.textColor = [UIColor blackColor];
headerLabel.highlightedTextColor = [UIColor whiteColor];
headerLabel.font = [UIFont systemFontOfSize:13];
headerLabel.frame = CGRectMake(2, 166, 300.0, 44.0);
headerLabel.text = @"Part No. Description Ext Cost"; // i.e. array element
[customView addSubview:headerLabel];
return customView;
}
Даже если были вызваны методы делегата, заголовок заголовка появится не в том месте (слишком низко). Его происхождение, вероятно, должно быть 0,0 вместо 2,166, поскольку это подзадача customView. – Anna