- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
if(section == 1)
{
// For Lable
UIView *view = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, tableView.bounds.size.width, 40)] autorelease];
tableView.sectionHeaderHeight = view.frame.size.height;
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(10, 10, view.frame.size.width - 20, 44)];
label.text = [self tableView:tableView titleForHeaderInSection:section];
label.font = [UIFont boldSystemFontOfSize:16.0];
label.shadowOffset = CGSizeMake(0, 1);
label.backgroundColor = [UIColor clearColor];
label.textColor = [UIColor whiteColor];
label.adjustsFontSizeToFitWidth = YES;
[label setLineBreakMode:NSLineBreakByTruncatingTail];
[label setNumberOfLines:0];
label.text = @「Your Text Here…..your Text Here」;
[view addSubview:label];
[label release];
return view;
}
return nil;
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
if(section == 1)
{
return 60.0;
}
return 0;
}
謝謝。它只在我使用靜態字符串的情況下才起作用。如果我在if子句中使用這樣的代碼:NSString * str = [NSString stringWithFormat:@「There are%d symbols」,[[[tableView cellForRowAtIndexPath:tappedRow] textLabel] text] length]]; return str; – LIAL
我得到了應用程序的崩潰 – LIAL
返回[NSString stringWithFormat:@「%@」,[firstsectionarray objectAtIndex:indexPath.row]]像這樣做所有部分,並注意numberofrowsinsection函數 –