Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UITableViewController scroll with extra space (like Notes application)

How do I replicate this behavior found in Notes app:

  1. You have a UITableViewController with items,
  2. You can scroll the list down (with lots of items),
  3. When you hit the bottom of the list, you can "overscroll" a bit, but the list wont scroll all the way back. There will be some space left under the last item. This space is utilized in Notes to display some layout image.

To demonstrate with photos: Photo 1

This is an "unscrolled" list. Its easy to create such using UITableViewController. And when you "pull" the list up, default UITableViewController just bounces back to this state.

However, Notes allows this: Photo 2

eg. After scrolling to leave a bit of space, don't have it bounce all the way back.

How do you replicate such behavior?

like image 331
Ondrej Skalicka Avatar asked Mar 04 '13 13:03

Ondrej Skalicka


1 Answers

Updating Kirualex response:

Ideal placement: UITableViewController viewDidLoad

Swift 3:

// Add 50 extra pixels at bottom of the list when scrolling
self.tableView.contentInset = UIEdgeInsets(top:0, left: 0, bottom: 50, right: 0)
like image 51
Jorge Ramírez Avatar answered Oct 08 '22 10:10

Jorge Ramírez