0

I am working on iOS app that needs to show information in expand collapse manner. For this I am using Header and section in headers. Though I have not so much understanding of it in iOS but same task I have achieved in Android using Expandable RecyclerView.

But In iOS I have followed the tutorial in that I have made two nibs and creating the Expandable like UiTableView.

Now when I expand the header the sections appear, and after last section there comes the new Header. I want to add the space between last section and new Header, but I am not successful in achieving this.

Any Idea how can I add space only to last section and new upcoming header?

Update 1:

This image is taken from another question over SO, but I have edited to show what I want. Look at the black space between last child/section of First header and new Header i.e Header 2 .... have a look at below picture

enter image description here

A.s.ALI
  • 1,992
  • 3
  • 22
  • 54

1 Answers1

4

You can achieve this by adding following delegate method of table view.

func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
    return 10.0
}

Here, you need to return height for footer which looks like blank space between two section.

Sagar Chauhan
  • 5,715
  • 2
  • 22
  • 56
  • but this is adding spacing in each headers, I just want to create the space between the last child and new coming header – A.s.ALI Dec 06 '18 at 09:53
  • @SharartiKAKI, Can you please show screenshot and describe where you want to add space ? – Sagar Chauhan Dec 06 '18 at 09:59
  • Thanks for image. But, could you please post image of your screen, So people can understand what actually issue with your UI. – Sagar Chauhan Dec 06 '18 at 10:16
  • i have no issue, but simple is that I have no space between last child new header – A.s.ALI Dec 06 '18 at 10:21
  • have you got it or not > – A.s.ALI Dec 06 '18 at 10:29
  • I'm using same things in my current project and using this method everything working fine. Could you please check background color of table view or view?, May be it's same as gap between last child and second section header, So are not able to see it. – Sagar Chauhan Dec 06 '18 at 12:32
  • Can you please share demo app for your UI? – Sagar Chauhan Dec 06 '18 at 12:37
  • Without your screen UI, I'm not able to fix issue whatever you are facing. If you can, please share just share image of your screen. One more thing, make sure you have connected delegate method of table view, otherwise this method will not work. – Sagar Chauhan Dec 06 '18 at 12:48
  • actually I have just got it with another way/ it is not a good way I know, but having UIView in custom cell,and if it is last cell of the header, I am making its height more – A.s.ALI Dec 06 '18 at 12:58
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/184849/discussion-between-sagar-chauhan-and-shararti-kaki). – Sagar Chauhan Dec 07 '18 at 04:32