ENSwiftSideMenu icon indicating copy to clipboard operation
ENSwiftSideMenu copied to clipboard

custom UITableView Cell for side menu

Open ghost opened this issue 10 years ago • 4 comments

I'm trying to implement a TableViewController with a custom cell like below.

class menuItem: UITableViewCell {
    @IBOutlet var menuLabel: UILabel!
    @IBOutlet var menuImage: UIImageView!
}

When I use this as a table view (connecting the outlets to the story board prototype cells with UILabel, UIImageView) it works well. But when I'm injecting it into the Navigation controller it fails to create a custom UITableView Cell.

  func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> menuItem {
    let cell = tableView.dequeueReusableCellWithIdentifier("cell", forIndexPath: indexPath) as! menuItem
    if cell == nil {
        cell = UITableViewCell(style: UITableViewCellStyle.Default, reuseIdentifier: "cell") as! menuItem
    }
    return cell  
  }

// cell value is always nil. Even after Manually creating in cell == nil condition

Can any one help me with this ?

ghost avatar Apr 23 '15 15:04 ghost

How do you create table view controller?

evnaz avatar Apr 24 '15 16:04 evnaz

I mean how do you create an instance of table view controller. You have to do it like this http://stackoverflow.com/questions/24035984/instantiate-and-present-a-viewcontroller-in-swift#answer-24036067

evnaz avatar Apr 25 '15 07:04 evnaz

@evnaz Thanks for the link. I'll try it and get back.

ghost avatar Apr 25 '15 09:04 ghost

Hi, I'm experimenting with a custom cell and I got this error:

'NSInternalInconsistencyException', reason: 'unable to dequeue a cell with identifier drawerCell - must register a nib or a class for the identifier or connect a prototype cell in a storyboard'

I did everything as usual when working with tableviews

I solved with this: https://github.com/evnaz/ENSwiftSideMenu/issues/19

thanks anyway :)

jgutierrez11 avatar Jan 13 '16 01:01 jgutierrez11