custom UITableView Cell for side menu
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 ?
How do you create table view controller?
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 Thanks for the link. I'll try it and get back.
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 :)