mindz-eye / MYTableViewIndex

A pixel perfect replacement for UITableView section index, written in Swift
MIT License
523 stars 52 forks source link

Calling tableViewIndex.reloadData() the second time causes infinite loop in TableViewIndex's layoutSubviews() #33

Closed 4tuneTeller closed 4 years ago

4tuneTeller commented 4 years ago

Everything works fine if I call the following code for the first time:

self.tableView.reloadData()
self.tableIndexController.tableViewIndex.reloadData()

but after I update data source of the table view, that code makes the app freeze because layoutSubviews() gets called infinitely in TableViewIndex. But I need to update the index view, what should I do?

4tuneTeller commented 4 years ago

I've spent some time debugging and it seems that it happens because of this line in the layoutSubviews() of the TableViewIndex class: backgroundView.frame = layout.backgroundFrame those are never equal which triggers the layoutSubviews() again every time.

4tuneTeller commented 4 years ago

Ok, so the problem occurred because I'm modifying the background frame myself too :)