Storyboard TableView with Segues to Multiple Views

前端 未结 3 1322
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-03 08:17

I am having an issue with designing a storyboard. I currently have an app in the app store that was designed with XIB files. I have a tableView placed on a UIViewControlle

3条回答
  •  温柔的废话
    2021-01-03 08:49

    Swift 3 Code
    Well, look at my piece of code I use to perform dynamic segue based on the type of the device type in the cell. :) Hope it helps.

    override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        let device = Cache.DEVICELIST[indexPath.row]
        let deviceType = device.type
    
        switch deviceType {
        case "camera":
            self.performSegue(withIdentifier: "DashCellToCamera", sender: self)
    
        case "gateway" :
            self.performSegue(withIdentifier: "DashCellToGateway", sender: self)
    
        case "tracker" :
            self.performSegue(withIdentifier: "DashCellToTracker", sender: self)
    
        case "panicbutton" :
            self.performSegue(withIdentifier: "DashCellToPanicButton", sender: self)
    
        default:
            break
            //do nothing just ignore this
        }
    }
    

提交回复
热议问题