Ios 仅更改UITableView中一个节的页脚大小
我有一个分组的静态UITableView,它包含4个部分。在所有4个部分中,我都有一个页眉,只有最后一个部分有一个页脚,表示应用程序的版本 因为我已经使用Interface Builder和Storyboard构建了我的UITableViewController,所以我可以在Inspector中设置页眉和页脚边距的大小,因此我将每个页眉和页脚边距的大小设置为10 但我面临的问题是,由于检查器中的页脚大小,表示页脚的UILabel被截断 我使用自定义标签,因为我把页脚标题放在中间,使它变白并改变字体的大小。 下面是代码:Ios 仅更改UITableView中一个节的页脚大小,ios,static,uilabel,uitableview,Ios,Static,Uilabel,Uitableview,我有一个分组的静态UITableView,它包含4个部分。在所有4个部分中,我都有一个页眉,只有最后一个部分有一个页脚,表示应用程序的版本 因为我已经使用Interface Builder和Storyboard构建了我的UITableViewController,所以我可以在Inspector中设置页眉和页脚边距的大小,因此我将每个页眉和页脚边距的大小设置为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;
}
}
问题是,如果我在Inspector中增加页脚边距的大小,那么每个部分的页脚边距都会增加,这会使各个部分之间的差距更大
我只想增加最后一部分的页脚,这样标签就不会被遮挡
我也尝试过在上面的代码中更改UIView和UILabel值,但没有成功
如果您能就此提供指导,我们将不胜感激 您可以使用委托方法-cgloattableview:UITableView*tableView heightforfooterInstitution:NSIntegersection 试着这样做:
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
CGFloat footerHeight = 0;
if (section == 3) {
footerHeight = 100;
}
return footerHeight;
}
您可以使用委托方法-cgloattableview:UITableView*tableView heightforfooterInstitution:NSIntegersection 试着这样做:
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
CGFloat footerHeight = 0;
if (section == 3) {
footerHeight = 100;
}
return footerHeight;
}
迅捷的
上面被接受的答案确实满足了我的需求,只是想在将来将其转换为Swift
override func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
var footerHeight: CGFloat = 0
if section == 3 {
footerHeight = 100
}
return footerHeight
}
迅捷的
上面被接受的答案确实满足了我的需求,只是想在将来将其转换为Swift
override func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
var footerHeight: CGFloat = 0
if section == 3 {
footerHeight = 100
}
return footerHeight
}
谢谢这么多垫子-这把把戏做得很完美。我真的很感谢你的回复,很抱歉回复太晚!再次感谢!谢谢这么多垫子-这把把戏做得很完美。我真的很感谢你的回复,很抱歉回复太晚!再次感谢!