ios - UITableView sections headers don't scroll synchronously -
i have strange behavior in table view sections. when scroll table sections headers stay on position , table view below scrolls. if scroll/touch headers both scrolling synchronously. idea wrong here?
class tvcontroller < uitableviewcontroller def viewdidload super @sections = [{:title=>"30.03", :bookings=>["opening balance"]}, {:title=>"31.03", :bookings=>["thai", "coffee"]}, {:title=>"02.04", :bookings=>["pizza"]}, {:title=>"03.04", :bookings=>["nido, view", "coffee ", "withdrawel ", "coffee "]}, {:title=>"07.04", :bookings=>["mautgebühren "]}, {:title=>"11.04", :bookings=>["tipp hofer alpl ", "meral ", "menterschwaige", "eis"]}, {:title=>"12.04", :bookings=>["flaucher"]}, {:title=>"14.04", :bookings=>["thai "]}, {:title=>"25.04", :bookings=>["atm", "samen schmitz", "edeka ", "maelu ", "clearence"]}, {:title=>"26.04", :bookings=>["auerdult ", "schneebesen"]}, {:title=>"28.04", :bookings=>["thai"]}, {:title=>"30.04", :bookings=>["bahnhof "]}, {:title=>"05.05", :bookings=>["thai"]}, {:title=>"07.05", :bookings=>["valleys "]}, {:title=>"10.05", :bookings=>["café "]}] @table = uitableview.alloc.initwithframe(self.view.bounds, style:uitableviewstylegrouped) @table.datasource = self @table.delegate = self self.view.addsubview @table end def tableview(tableview, cellforrowatindexpath: indexpath) @reuseidentifier ||= 'account_table_cell' cell = tableview.dequeuereusablecellwithidentifier(@reuseidentifier) || begin uitableviewcell.alloc.initwithstyle(uitableviewcellstyledefault, reuseidentifier:@reuseidentifier) end cell.textlabel.text = self.booking(indexpath) cell end def numberofsectionsintableview(tableview) self.sections.length end def tableview(tableview, numberofrowsinsection: section) self.sections[section][:bookings].length end def tableview(tableview, titleforheaderinsection: section) self.sections[section][:title] end def booking(indexpath) @sections[indexpath.section][:bookings][indexpath.row] end end
if understanding scenario correctly (pardon me if not):
purpose of headers in table view 1 happening you. headers supposed present in view @ top of rows, until rows of headers scrolled, once rows scrolled, header moves self well.
if want scroll header along rows, should consider making row purpose , not header, not creating sections.
if want using headers follow link "jrg-developer" provided : change default scrolling behavior of uitableview section header
but, if trying create normal scrolling away headers rows, recommend use rows purpose , create custom row fulfill purpose of header.
Comments
Post a Comment