user3745888 user3745888 - 1 year ago 102
Swift Question

How to add two custom cell into tableview in storyboard in Swift?

I have a tableView with two different custom cell. One cell have a switch and other a image, I have Two separated custom class for the cells, identifiers.. but I can't see this. i don't know if I need change the configuration in story board to dynamic or other thing.. Can I show two different custom cells


Answer Source

Can you use something like:

override func tableView(tableView: UITableView?, cellForRowAtIndexPath indexPath: NSIndexPath?) -> UITableViewCell? {

    if (criteria for cell 1) {
        let cell = tableView!.dequeueReusableCellWithIdentifier("cell1", forIndexPath: indexPath) as? Cell1
        return (cell)
    else {
        let cell = tableView!.dequeueReusableCellWithIdentifier("cell2", forIndexPath: indexPath) as? Cell2
        return (cell)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download