I'm trying to create static cells in a UITableViewCell. I've started by adding 2 cells in Interface Builder and given them the identifier title and news. Then I've created an array with these two identifiers and added it to cellForRowAtIndexPath. However I keep getting following error:
'unable to dequeue a cell with identifier title - must register a nib or a class for the identifier or connect a prototype cell in a storyboard'
The array
var menuItems = ["title", "news"]
tableView delegate methods
override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
// #warning Potentially incomplete method implementation.
// Return the number of sections.
return 1
}
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
// #warning Incomplete method implementation.
// Return the number of rows in the section.
return 2
}
override func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
return 64
}
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier(menuItems[indexPath.row], forIndexPath: indexPath) as! UITableViewCell
cell.backgroundColor = UIColor(white: 0.2, alpha: 1.0)
var bottomView: UIView = UIView(frame: CGRectMake(0, cell.frame.height-1, cell.frame.width, 1))
bottomView.backgroundColor = UIColor(white: 0.2, alpha: 0.15)
cell.contentView.addSubview(bottomView)
return cell
}
UITableViewControllerwith the tableViewController in interface builder?