يبدو أن ارتفاع TableHeaderview هو 0
-
20-09-2019 - |
سؤال
حاولت تجاوز TableHeaderview الثاني. ولكن يبدو أن ارتفاعه في الطريقة التي يبدو أن HeightforheaderInsection هي 0. لا يمكنني شرح ذلك ، هل يجب أن أضعها في Ivar لأنه في ViewforheaderInsection ، يمكنني ضبط العرض دون أي مشاكل.
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
if(section == 0)
return @"Adding a new list";
else
return @"Other lists";
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
if(section == 0) {
return tableView.tableHeaderView;
} else {
UIView *view = [[[UIView alloc] initWithFrame:CGRectMake(10, 10, 100, 50)] autorelease];
view.backgroundColor = [UIColor redColor];
return view;
}
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
if(section == 0)
return tableView.tableHeaderView.frame.size.height;
else
return 30;
}
المحلول
أعتقد أنك تربك رأس الجدول ورأسه لكل قسم ، فهي مختلفة. لا يوجد "Talledheaderview الثاني" ، أ UITableView
لديه واحد tableHeaderView
ثم يعتمد على viewForHeaderInSection
و heightForHeaderInSection
طرق لوضع مشاهدات رأس مخصصة لكل قسم ، وإلا فإنك تستخدم فقط titleForHeaderInSection
لوضع النص هناك.
لا تنتمي إلى StackOverflow