ios - Make UIView scroll with UITableView but pin to top out of view -


i have view controller comprised of navigation bar, followed uiview has 2 uibuttons added subviews. there uitableview underneath begins @ bottom of container uiview.

at moment, when user scrolls uitableview goes behind uiview , uibuttons. want happen uiview , uibuttons move table view value of height in case 58 pixels. flow this...

1) table scrolls , uiview moves first 58 pixels.

2) user continues scroll table uiview "pins" out of view under navigation bar.

3) when user scrolls table down uiview picked , dragged view. believe new facebook app similar in timeline.

i don't want set uiview tableheaderview of table have pull-to-refresh sits above buttons , looks terrible. i've tried playing around contentoffset properties of underlying scrollview of table have hit brick wall.

any advice on start appreciated.

thanks

edit: gotten little further , using code move frame of uiview.

-(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 > 0)         {             cgrect newframe = self.btnbackground.frame;             newframe.origin.x = 0;             newframe.origin.y = -self.tableview.contentoffset.y;             [self.btnbackground setframe: newframe];         }    } 

the problem scrollviewdidscroll delegate method doesn't fired enough if table view scrolled fast. result uiview doesn't quite make way original position when scroll quickly.

well asked question (y) , me first : use main uiscrollview contains both topview , tableview under , has same width top uiview , uitableview , set height height(tableview) + height(topview). second : since uitableview subclass of uiscrollview can use scrollviewdidscroll delegate know if tableview scrolled or down. in cas have 2 cases :

1) tableview scrolled = > set content offset of main scrollview

[scrollview setcontentoffset:cgpointmake(0, 58) animated:yes]; 

2) when table view scrolled down can reset content offset again

 [scrollview setcontentoffset:cgpointmake(0, 0) animated:yes]; 

Comments