How to create padding(spacing) between rows in tablview

后端 未结 5 769
情深已故
情深已故 2020-12-15 12:21

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 group

5条回答
  •  庸人自扰
    2020-12-15 12:50

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

    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;
    }
    

提交回复
热议问题