gpt4 book ai didi

iphone - TableView titleForHeaderInSection

转载 作者:行者123 更新时间:2023-12-01 18:01:16 25 4
gpt4 key购买 nike

我的应用程序在4.3.1模拟器中显示此内容,在5.0模拟器中显示此内容。

这是代码:

- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
return @"";
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
return [[Singleton sharedInstance] getTitleSectionView:segmentedControl.selectedSegmentIndex inDay:section];
}
-(UIView *)getTitleSectionView:(int)week inDay:(int)day;
{
UILabel *lab=[[[UILabel alloc]init]autorelease];
lab.frame=CGRectMake(5, 0,320,20);
lab.text=[[Singleton sharedInstance] getTitleSection:week inDay:day];
lab.backgroundColor=[UIColor clearColor];
lab.textColor=[UIColor whiteColor];
lab.font = [UIFont fontWithName:@"Arial" size:14];

UIImageView * imv = [[[UIImageView alloc]initWithFrame:CGRectMake(0,0, 320, 20)]autorelease];
imv.image=[UIImage imageNamed:@"section-header-bg.png"];

UIView *view = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 20)]autorelease];
[view addSubview:imv];
[view addSubview:lab];

Week *currentWeek = nil;
if(week)
currentWeek = nechetNedel;
else
currentWeek = chetNedel;

NSMutableArray *dayArray = [currentWeek.days objectAtIndex:day];
if([dayArray count] >0)
return view;
return nil;
}

可能是什么问题,为什么在5.0模拟器中出现几节呢?我试图删除 - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section方法,但没有帮助。我删除了 (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section这个方法,行消失了

最佳答案

您应该为空节返回nil

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section;


- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section;

应该返回0

然后它将起作用。是iOS 5.x问题(或功能)

关于iphone - TableView titleForHeaderInSection,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9418240/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com