【发布时间】:2013-11-13 11:57:22
【问题描述】:
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
NSString *sectionTitle = @"";
if(section == 0)
sectionTitle = @"Overall Progress";
else
sectionTitle = [[courses objectAtIndex:section-1] objectForKey:@"course-name"];
// Create label with section title
UILabel *label = [[[UILabel alloc] init] autorelease];
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone)
{
label.frame = CGRectMake(15, 10, 300, 30);
label.font = [UIFont boldSystemFontOfSize:14];
}
else
{
label.frame = CGRectMake(50, 20, 600, 60);
label.font = [UIFont boldSystemFontOfSize:19];
}
label.text = sectionTitle;
label.backgroundColor = [UIColor clearColor];
[label sizeToFit];
// Create header view and add label as a subview
UIView *view;
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone){
view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 100)];
}
else{
view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 640, 500)];
view.backgroundColor = [UIColor clearColor];
}
[view addSubview:label];
[view autorelease];
return view;
}
在此代码部分中,当我调试时返回 1,因此第 0 部分的代码不会被执行。因此,我无法在表格标题视图中获得总体进度文本。
【问题讨论】:
-
虽然它在 iOS 6 及更低版本中运行良好
-
你遇到什么样的错误?
-
我没有遇到任何错误。好像它不是从第 0 节开始的,所以我的第 0 节代码没有被执行....
-
请同时发布您的其他代表方法
-
第 0 部分有多少行?
标签: ios iphone objective-c uitableview ios7