如何在tablview中的行之间创建填充(间距) [英] How to create padding(spacing) between rows in tablview

查看:89
本文介绍了如何在tablview中的行之间创建填充(间距)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这不是重复我读了关于这个的其他问题,他们都没有给我我需要的东西,我正在创建一个带有自定义单元格的表视图,并且样式被分组。我在每行内部有1个ImageView,它比整行要小。我需要创建多少个单元格,这是我从db得到的东西,所以我不能使用静态单元格,我需要在行之间有间距,我无法弄清楚如何做这个。我尝试制作单元格Bigger(320,143)并使其隐藏,我设法做但当你按下图像外它仍然表现得像我按下单元格
这几乎是我想要达到的目标

This isn't a duplicate I read the other questions regarding this and none of them gave me what i needed , I'm creating a table view with custom cell and the style is grouped. I have 1 ImageView inside each row that is smaller then the whole row.How many cells I need to create is somthing i get from the db so I cant use static cells I need to have spacing between the rows,I cant figure out how to do this. I tried making the cell Bigger (320,143) and making it invisible which i managed to do but then when you press outside the image it still acting like i pressed the cell this is pretty much what i want to achieve

但是会发生这种情况:

我需要单元格为图像大小,但在不同行之间有间距。我怎么能这样做?

I need the cell to be the images size but to have spacing between diffrent rows. how can i do this?

推荐答案

很多方法可以做到这一点,但我发现这是最简单,最简单的方法。

Many ways to do it, but I found this is the simplest and easiest way to do so.

设置 UITableView 样式分组。然后有两个部分,每个部分只有一行。替换行中的图像。

Set UITableView style grouped. Then have two sections and each section has only one row. Replace your image in the row.

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    //array is your db, here we just need how many they are
    return [array count];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 1;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    //place your image to cell
}
- (float)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    //this is the space
    return 50;
}

这篇关于如何在tablview中的行之间创建填充(间距)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆