0

I want to create a expandable section with swift. For example in the picture below, Microsoft Outlook IOS application has a expandable section.

enter image description here

When you click to the section , it seems like below.

enter image description here

Is this section needs extra code or xcode already has a feature for this? Thanks in advance.

OmerArslan
  • 364
  • 1
  • 2
  • 14

2 Answers2

0

You need to create a delegate for the custom section you have created, assign it to the ViewController and in the delegate method call this when the user taps on it.

insertRows(at indexPaths: [IndexPath], with animation: UITableViewRowAnimation)

and when the user taps again on the section check if the section is open, if yes then call this method.

deleteRows(at indexPaths: [IndexPath], with animation: UITableViewRowAnimation)

And don't forget to call tableView.reloadData() after these methods.

J. Koush
  • 1,028
  • 1
  • 11
  • 17
0

I've recently used the same in one of my project but it was in objective-c, i know one something which will help you. Please have a look,

Swift Expandable Section

I hoe it will helps you.

Thanks.

Samkit Shah
  • 721
  • 1
  • 7
  • 18