1

In my app I have a UITableView with a UIView placed above its frame:

 -----------
|  UIView   |
 -----------
|           | 
|           |
|UITableView|
|           |
|           |
 -----------

When I scroll the tableView up the UIView is pushed up out of the screen and when the contents of the tableView are scrolled down the UIView gets pushed back into the screen. All the movement of the UIView happens with the same speed as the user scrolls. So if the user scroll 10px the UIView is only moved 10px.

The problem I am having is the resizing of the tableView. I want it to resize according to the y-position of the UIView so that there is never any space between then.

The moving of the UIView is working perfectly but the resizing of the tableView not at all. I really freezes up the main thread and it is really edgy.

- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{

    Some code for moving the UIView...

    UpdateFrameY(_tableViewController.tableView, diff);
    UpdateFrameHeightOnDiff(_tableViewController.tableView, diff);
}

Is there a better way I can do this? I am actually trying to copy this behavior from the FB app. It works really smoothly there. Thanks a lot!

rmaddy
  • 314,917
  • 42
  • 532
  • 579
freshking
  • 1,824
  • 18
  • 31
  • possible duplicate of [Change UITableView height dynamically](http://stackoverflow.com/questions/14223931/change-uitableview-height-dynamically) – Khawar Ali May 12 '14 at 14:23
  • I'd like to know more details, like if the cells height is changed with the table hight update. A sample project would be perfect. – A-Live May 12 '14 at 15:14

1 Answers1

0

Do not change the uitableview heigth. Just change its content insets and place your UIView over the UITableView (so the UIView and the UITableView will have the same frame origin); you will have some performance improvements.

Jacopo Berta
  • 265
  • 2
  • 14
  • I actually tried this but I had a problem with my content insets because I am using a UIRefreshControl inside my UITableViewController. This always messes with the content insets. – freshking May 12 '14 at 22:08
  • you can try not to animate the content insets. just make it fixed. When the UITableView will scroll to the top most cell, the top UIView will always have its biggest frame – Jacopo Berta May 13 '14 at 07:31