[英]How to change the height BETWEEN sections in GROUPED UITableView?
[英]How to insert UIImageView between two sections of UITableView?
我在应用程序中进行了设计,就像我的UITableView中有4个部分一样,我需要在同一张表的各部分之间插入UIImageView和UILabel。 是否可以这样做?
请给我一个路径。谢谢。
请参阅以下UITableViewDelegate方法:
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger) section
-(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger) section
您可能需要将图像视图和标签封装在IUView容器中,然后从这些方法之一返回容器。 这取决于您想要呈现它们的方式和方式。
您的表格样式为UITableViewStyleGrouped
吗?
如果是这样,请使用UITableViewDelegate
viewForHeaderInSection:
或viewForFooterInSection:
方法。 创建一个视图,将图像和标签添加到该视图,然后从以上两个委托方法中的任何一个返回到视图。 我想,您正在使用图像和标签作为该部分的标题。 因此, tableView:viewForHeaderInSection:
是您所需要的。
我以这种方式实现,并且根据我的需要显示了图像。谢谢您显示的路径,如果有其他需要的人,我正在显示代码。谢谢。
-(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger) section
{
UIView *header = [[UIView alloc] initWithFrame:CGRectMake(0,5,320,40)];
UIImageView *imgAdbar = [[UIImageView alloc]initWithFrame:CGRectMake(header.frame.origin.x,header.frame.origin.y,header.frame.size.width,header.frame.size.height)];
[imgAdbar setImage:[UIImage imageNamed:@"ad2.png"]];
[header addSubview:imgAdbar];
header.backgroundColor = [UIColor clearColor];
return header;
}
我认为您需要制作一个自定义视图,其中包含四个单独的表,每个表都有一个部分,并将imageview和uilabel放在每个表之间。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.