how to scroll last tableview item to the top

Discussion in 'iOS Development' started by cybohemia, Jun 25, 2009.

  1. cybohemia

    cybohemia New Member

    Jan 25, 2009
    Likes Received:
    iPhone 3G (Black)
    I'm working on an app that uses a TableView and scrolls chosen items to the top of the view.

    I'm using the scrollToRowAtIndexPath method with UITableViewScrollPositionTop as the atScrollPosition argument.

    Here's the tricky part: even when I don't have enough items to fill the screen below the selected item, I would still like the selected item to scroll to the top, leaving the bottom blank. But it seems like the system doesn't allow that - when all the remaining items are visible, it no longer scrolls a particular item to the top if it is already visible somewhere on the screen. I guess this makes sense in general but, for my app, I would like to be able to have it go to the top, anyway.

    I was thinking of creating some blank elements but was wondering if I've missed anything more elegant before I hack away.

    Thanks for any thoughts!
  2. gojohnnyboi

    gojohnnyboi Well-Known Member

    Jan 25, 2008
    Likes Received:
    get the contentoffset of the last cell, and use the scroll view methods that the table view inherits to scroll to that contentoffset, but add x amount to the height of the offset.

Share This Page