croigsalvador
croigsalvador

Reputation: 2013

Change Titles of custom Section view in UITableView

I have a UITableView with expand and collapse cells when I tap in the sections. Now I want to collapse the cells again when I tap in one of this cells and give the name of this cell to the section up there. I think that collapse is not a problem but I do not know how to change the name. I have done everything programmatically. Thank you

Upvotes: 0

Views: 77

Answers (1)

Joiningss
Joiningss

Reputation: 1320

You can try like this:

  1. add an observer in custom section view to update title. Because section view is reused in UITableView,need a parameter(such as: int sectionIndex) to definite witch section the section view belong to.

  2. in tableView:viewForHeaderInSection: set sectionView.sectionIndex with indexPath.section

  3. in tableView:didSelectRowAtIndexPath: post a notification with indexPath.section and title string

Upvotes: 1

Related Questions