swift - UITableView Prototype cell not found -



swift - UITableView Prototype cell not found -

every one. after lots of search , different test code doesn't work yet...

i seek simple uitableview simple prototype cell whit using "dequeuereusablecellwithidentifier" function doesn't found prototype cell.

my code :

import foundation import uikit class danceclubviewcontroller: uiviewcontroller, uitableviewdelegate, uitableviewdatasource { @iboutlet weak var tableviewsound: uitableview! override func viewdidload() { super.viewdidload() self.tableviewsound.registerclass(uitableviewcell.self, forcellreuseidentifier: "cellvote") self.tableviewsound.datasource = self self.tableviewsound.delegate = self self.tableviewsound.reloaddata() } override func viewwillappear(animated: bool) { super.viewwillappear(animated) } @ibaction func backtoviewplay(sender: anyobject) { self.navigationcontroller?.poptorootviewcontrolleranimated(true) } func tableview(tableview:uitableview, numberofrowsinsection section:int)->int { homecoming 10 } func tableview(tableview: uitableview, cellforrowatindexpath indexpath: nsindexpath) -> uitableviewcell { var cell : uitableviewcell = self.tableviewsound.dequeuereusablecellwithidentifier("cellvote") uitableviewcell homecoming cell }

if had had problem?

the identifier prototype cell : cellvote

the key address label create custom tableviewcell class in file:

import uikit class dancecell: uitableviewcell { @iboutlet weak var num: uilabel! //connect label }

then viewcontroller:

import foundation import uikit class danceclubviewcontroller: uiviewcontroller, uitableviewdelegate, uitableviewdatasource { @iboutlet weak var tableviewsound: uitableview! override func viewdidload() { super.viewdidload() self.tableviewsound.datasource = self self.tableviewsound.delegate = self self.tableviewsound.reloaddata() } override func viewwillappear(animated: bool) { super.viewwillappear(animated) } @ibaction func backtoviewplay(sender: anyobject) { self.navigationcontroller?.poptorootviewcontrolleranimated(true) } func tableview(tableviewsound:uitableview, numberofrowsinsection section:int)->int { homecoming 10 } func tableview(tableviewsound: uitableview, cellforrowatindexpath indexpath: nsindexpath) -> uitableviewcell { allow cell = tableviewsound.dequeuereusablecellwithidentifier("cellvote", forindexpath: indexpath) dancecell cell.num.text = "hello" homecoming cell } }

i removed stuff, , added key line in 'cellforrowatindexpath' function register cell. able communicate label. create sure prototype cell has set 'cellvote' identifier in @ attributes inspector.

swift prototype cell

Comments

Popular posts from this blog

assembly - What is the addressing mode for ld, add, and rjmp instructions? -

vowpalwabbit - Interpreting Vowpal Wabbit results: Why are some lines appended by "h"? -

Is there a way to convert an HTML page styled with Bootstrap CSS into email-compatible html? -