Note that there are some explanatory texts on larger screens.

plurals
  1. POMake UIView scroll with UITableView but pin to top out of view
    primarykey
    data
    text
    <p>I currently have a <code>view controller</code> that is comprised of a <code>Navigation bar</code>, followed by a <code>UIView</code> that has two <code>UIButtons</code> added as subViews. There is then a <code>UITableView</code> underneath that begins at the bottom of the container <code>UIView</code>.</p> <p>At the moment, when the user scrolls the <code>UITableView</code> it goes behind the <code>UIView</code> and <code>UIButtons</code>. What I actually want to happen is for the <code>UIView</code> and <code>UIButtons</code> to move up with the table view but only by the value of their height which in this case is 58 pixels. The flow would be like this...</p> <p>1) Table scrolls and the <code>UIView</code> moves with it for the first 58 pixels.</p> <p>2) The user continues to scroll the table but the <code>UIView</code> "pins" itself just out of view under the <code>navigation bar</code>.</p> <p>3) When the user scrolls the table back down the <code>UIView</code> is then picked up and dragged back into view. I believe the new Facebook app does something similar in the timeline.</p> <p>I don't want to set the <code>UIView</code> as the <code>TableHeaderView</code> of the table as I also have a pull-to-refresh which then sits above the buttons and looks terrible. I've tried playing around with the <code>contentOffset</code> properties of the underlying <code>scrollview</code> of the table but have hit a brick wall.</p> <p>Any advice on where to start would be appreciated.</p> <p>Thanks</p> <p>EDIT: I am gotten a little further and using this code to move the frame of the UIView. </p> <pre><code>-(void) scrollViewDidScroll:(UIScrollView *)scrollView { NSLog (@"Content Offset: %f", self.tableView.contentOffset.y); NSLog (@"Button Frame: %f", self.btnBackground.frame.origin.y); if (self.tableView.contentOffset.y &gt; 0) { CGRect newFrame = self.btnBackground.frame; newFrame.origin.x = 0; newFrame.origin.y = -self.tableView.contentOffset.y; [self.btnBackground setFrame: newFrame]; } } </code></pre> <p>The problem now is that the scrollViewDidScroll delegate method doesn't get fired quickly enough if the table view is scrolled fast. The result is that the UIView doesn't quite make all way back to its original position when scroll quickly.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload