【发布时间】:2014-04-12 12:37:12
【问题描述】:
我有一个分组的静态UITableView,其中 4 个部分。在所有 4 个部分中,我都有一个页眉,只有最后一个部分有一个页脚(代表应用程序的版本)。
因为我已经使用Interface Builder 和Storyboard 建立了我的UITableViewController,所以我可以在检查器中设置页眉和页脚边距的大小,因此我将每个设置为10。
我面临的问题是,由于检查器中的页脚大小,代表页脚的 UILabel 被截断。
我正在使用自定义标签,因为我将页脚标题放在中间,使其变为白色并更改字体大小。
代码如下:
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
if (section == 3)
{
CGRect screenRect = [[UIScreen mainScreen] applicationFrame];
UIView* headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 80, screenRect.size.width, 44.0)];
UILabel *label=[[UILabel alloc]initWithFrame:CGRectMake(0, 80, tableView.frame.size.width, 80.0)];
label.textAlignment = NSTextAlignmentCenter;
label.textColor = [UIColor whiteColor];
NSString* currentAppVersion = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"];
label.text = [NSString stringWithFormat:@"Version: %@", currentAppVersion];
label.font = [UIFont systemFontOfSize:14];
[headerView addSubview:label];
return label;
}
else
{
return nil;
}
}
问题是,如果我在检查器中增加页脚边距的大小,它会为每个部分增加它,然后使部分之间的间隙变得更大。
我只想增加最后一节的页脚,以免标签被遮挡。
我也尝试过更改上面代码中的 UIView 和 UILabel 值,但没有成功。
对此的任何指导将不胜感激。
【问题讨论】:
标签: ios static uilabel uitableview