Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

custom UITableView Cell for side menu #59

Open
ghost opened this issue Apr 23, 2015 · 4 comments
Open

custom UITableView Cell for side menu #59

ghost opened this issue Apr 23, 2015 · 4 comments

Comments

@ghost
Copy link

ghost commented Apr 23, 2015

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 ?

@evnaz
Copy link
Owner

evnaz commented Apr 24, 2015

How do you create table view controller?

@evnaz
Copy link
Owner

evnaz commented Apr 25, 2015

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

@ghost
Copy link
Author

ghost commented Apr 25, 2015

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

@jgutierrez11
Copy link

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:
#19

thanks anyway :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants