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
but this is what happens:
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.
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;
}
You can do it in just 3 lines.
First set gray color of your main view after that follow these lines.
cell.separatorInset = UIEdgeInsetsMake(20, 20, 20, 20);
cell.layer.borderWidth = 5;
cell.layer.borderColor = [UIColor whiteColor].CGColor;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With