iphone - UITableView - How to keep table rows fixed as user scrolls -


i'd able fix position of rows in uitableview user scrolls.

specifically, have table whereby rows "headers" rows follow, , i'd header stay @ top of screen user scrolls up. move out of way when user scrolls far enough next header row take place.

a similar example any.do app. "today", "tommorrow" , "later" table rows visible on screen.

does have suggestions how implemented?

i'm thinking of follow tabledidscroll delegate , positioning own cell in appropriate place in front of table view. problem @ other times i'd these cells real table cells can be, example, reordered user.

thanks,

tim

i've been playing , i've come simple solution.

first, add single uitableviewcell property controller. should initialize such looks row cells we'll use create false section headers.

next, intercept scrolling of table view

- (void)scrollviewdidscroll:(uiscrollview *)scrollview {     // add logic here determine section header. example, use      // indexpathsforvisiblerows visible index paths,      // should able table view row corresponds current      // section header. how works implementation dependent.     //     // if current section header has changed since pervious scroll request      // (because new 1 should @ top of screen) should     // update contents.      indexpath *indexpathofcurrentheadercell = ... // depends on implementation     uitableviewcell *headercell = [self.tableview cellforrowatindexpath:indexpathofcurrentheadercell];      // if exists it's on screen. hide our false header      if (headercell)         self.cellheader.hidden = true;      // if doesn't exist (not on screen) or if it's partially scrolled off top,     // position our false header @ top of screen      if (!headercell || headercell.frame.origin.y < self.tableview.contentoffset.y )     {         self.cellheader.hidden = no;         self.cellheader.frame = cgrectmake(0, self.tableview.contentoffset.y, self.cellheader.frame.size.width, self.cellheader.frame.size.height);     }      // make sure it's on top of other cells      [self.tableview bringsubviewtofront:self.cellheader]; } 

finally, need intercept actions on cell , right thing...


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -