ios - Multiple custom UITableView cells and sections -
i'm trying create look:
right have this:
three prototype cells identifiers , custom cells respectively top bottom as
id
cellstyle
cellstyle2
cellstyle3
with custom cell classes merely having capital c.
this code far:
what i'm trying change dequeue cell different custom cell classes able access properties , change labels , uiimageview. method not working cell.label.text
not recognized. tried creating 3 different variables cell so.
var cellstyle: cellstyle var cellstyle2: cellstyle2 var cellstyle3: cellstyle3
what return
function then?
questions:
- are either methods standard practice? if not, standard code accomplish i'm trying do?
- to cells top 3 buttons on prototype need inset? have in runtime
layer.bordercolor layer.borderwidth layer.cornerradius layer.maskstobounds
- how configure
numberofrowsinsection
multiple sections?
this update previous code based on comments.
override func tableview(tableview: uitableview, cellforrowatindexpath indexpath: nsindexpath) -> uitableviewcell { switch indexpath.row { case 0: var cell = tableview.dequeuereusablecellwithidentifier("cellstyle", forindexpath: indexpath) as! cellstyle cell.label?.text = "friends" // configure cell case 1: var cell = tableview.dequeuereusablecellwithidentifier("cellstyle2", forindexpath: indexpath) as! cellstyle2 // configure cell cell.label?.text = "random" case 2: var cell = tableview.dequeuereusablecellwithidentifier("cellstyle", forindexpath: indexpath) as! cellstyle // configure cell cell.label?.text = "judge" default: // default cell no text cell.textlabel?.text = "" } switch indexpath.section { case 0: var cell = tableview.dequeuereusablecellwithidentifier("cellstyle3", forindexpath: indexpath) as! cellstyle3 // configure cell cell.label?.text = "" // todo: need put name opponent _user reference here // cell.friendprofilepic.image = //query facebook api profile picture of friend facebook id "opponent" case 1: var cell = tableview.dequeuereusablecellwithidentifier("cellstyle3", forindexpath: indexpath) as! cellstyle3 // configure cell cell.label?.text = "" // todo: need put name opponent _user reference here // cell.friendprofilepic.image = //query facebook api profile picture of friend facebook id "opponent" case 2: var cell = tableview.dequeuereusablecellwithidentifier("cellstyle3", forindexpath: indexpath) as! cellstyle3 // configure cell cell.label?.text = "" // todo: need put name opponent _user reference here // cell.friendprofilepic.image = //query facebook api profile picture of friend facebook id "opponent" default: // default cell no text cell.textlabel?.text = "" } // configure cell... return cell }
Comments
Post a Comment