在这里,我已经设置了描述,价格以及从-到的位置,但无法设置日期和时间,如上图所示。格式面临一些问题,相应地在一个标题中设置日期,在另一个标题中设置时间。如果任何显示如何设置嵌套标题的链接对我有很大帮助。
提前致谢。
最佳答案
是的,如图,中间不能加分隔符,我也试过了
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
NSMutableArray *arrdate=[[NSMutableArray alloc]init];
arrdate=[date1 objectAtIndex:section] ;
NSLog(@"%@",arrdate);
NSMutableArray *arrtime=[[NSMutableArray alloc]init];
arrtime=[time objectAtIndex:section];
NSString *strvalue=[arrdate objectAtIndex:0];
UIView *view;
if([strvalue isEqualToString: strcheck])
{
view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, tableView.frame.size.width, 15)];
/* Create custom view to display section header... */
UILabel *label1 = [[UILabel alloc] initWithFrame:CGRectMake(10, 5, tableView.frame.size.width, 15)];
[label1 setFont:[UIFont boldSystemFontOfSize:12]];
strcheck=[arrdate objectAtIndex:0] ;
NSString *string =[arrtime objectAtIndex:0];
/* Section header is in 0th index... */
[label1 setText:string];
[view addSubview:label1];
}
else{
/* Create custom view to display section header... */
view= [[UIView alloc] initWithFrame:CGRectMake(0, 0, tableView.frame.size.width, 100)];
//main time
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(10, 5, tableView.frame.size.width, 15)];
[label setFont:[UIFont boldSystemFontOfSize:12]];
strcheck=[arrdate objectAtIndex:0] ;
/* Section header is in 0th index... */
[label setText:strcheck];
[view addSubview:label];
//time..
UILabel *labeltime = [[UILabel alloc] initWithFrame:CGRectMake(10,20, tableView.frame.size.width, 15)];
[labeltime setFont:[UIFont boldSystemFontOfSize:12]];
NSString *stringtime =[arrtime objectAtIndex:0];
/* Section header is in 0th index... */
[labeltime setText:stringtime];
[view addSubview:labeltime];
}
return view;
但在滚动 tableview 时,日期 View 会受到干扰。
关于ios - 用户界面 TableView : Nested Header sections,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34870872/