i'm looking create uitableview containing 3 sections (each section displaying centered uilabel), within each section there dynamic number of cells. first of cells (maincell) have image view , label, , final number of dynamic cells (detailcell) have information based on maincell. information fixed there 3 sections. have idea do? split them 3 tables rather them in 1 if possible. i've tried playing around grouped tables i'm not sure on how have varying number of detailcells each maincell.
i've attached image should explain i'm trying do.
any appreciated, thanks!
while don't know data source, this:
class mytableviewcontroller: uitableviewcontroller { override func viewdidload() { super.viewdidload() } // mark: - table view data source override func numberofsectionsintableview(tableview: uitableview) -> int { return 3 } override func tableview(tableview: uitableview, numberofrowsinsection section: int) -> int { return 7 } override func tableview(tableview: uitableview, cellforrowatindexpath indexpath: nsindexpath) -> uitableviewcell { var cell:uitableviewcell? if indexpath.row % 3 == 0 { // "maincell" cell = tableview.dequeuereusablecellwithidentifier("maincell", forindexpath: indexpath) } else { // "detailcell" cell = tableview.dequeuereusablecellwithidentifier("detailcell", forindexpath: indexpath) } return cell! } override func tableview(tableview: uitableview, viewforheaderinsection section: int) -> uiview? { let cell = tableview.dequeuereusableheaderfooterviewwithidentifier("headercell") return cell } }
the storyboard have multiple cell types represented:
the result this:
Comments
Post a Comment