Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are your favourite UITableView / UITableViewCell tricks? [closed]

UITableView is a very powerful class, powering many navigation and preference views on iPhone. Many people have come up with useful UITableView tips, tricks and samples:

  • various ways to use Interface Builder for table cells
  • how to create preference-style cells
  • ensuring good scrolling speed
  • etc.

Please post your favourite tips on using UITableView, one tip per question. I'll start by posting the ones I found on Stack Overflow and the ones from my bookmarks.

like image 816
Andrey Tarantsov Avatar asked May 09 '09 14:05

Andrey Tarantsov


1 Answers

Ever wondered what UITableViewController really does?

  • In viewWillAppear, it deselects any selected rows, with animated:YES.

    This by the way is why when you navigate back in UINavigationController, the row you've previously touched is nicely deselected with animation. When you pushed a new view controller onto UINavigationController, you've left the row selected. When you pop it and go back to the table view, viewWillAppear fires and deselects the row. UINavigationController does not even know about this happening.

  • In viewWillAppear, it calls reloadData if the table view contains no rows.

  • In viewDidAppear, it calls flashScrollIndicators.

  • It monitors the keyboard appearing and disappearing and resizes the table view appropriately so that when you tap a text field in a table view, it remains visible after the keyboard appears.

If you don't need the keyboard monitoring behaviour, it is fairly easy to do everything else yourself if you need to.

like image 114
Andrey Tarantsov Avatar answered Nov 16 '22 03:11

Andrey Tarantsov