So I am trying to have 3 different segues with 3 different section cells in a tableview. I am getting the initial tableview to populate with the custom cell data, but having trouble setting each cell to segue to each corresponding new ViewController...So 3 cells with 3 different segues is what I want...appreciate the help!
class ProfileTableViewController: UITableViewController {
var tableData: [String] = ["milan", "parisTower", "alps_1-blur", "alps_1", "meStanding"]
//register TravelBook Custom Cell
let nib = UINib(nibName: "TravelBookCell", bundle: nil)
tableView.registerNib(nib, forCellReuseIdentifier: "TravelBookCell")
self.tableView.dataSource = self
}
// MARK: - Table view data source
override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
return 3
}
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
if(section == 0) {
return 1
}
if(section == 1) {
return 1
}
else {
return tableData.count
}
}
override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
_ = tableView.cellForRowAtIndexPath(indexPath)
tableView.deselectRowAtIndexPath(indexPath, animated: true)
performSegueWithIdentifier("TravelBookDetailSegue", sender: TravelBookTableViewCell())
}
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
}
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
switch indexPath.section{
// 1st custom cell
case 0:
let myProfile = tableView.dequeueReusableCellWithIdentifier("ProfileHeaderCell") as! VideoTableViewCell
myProfile.frame.size = CGSize(width: 600.0, height: 60.0)
return myProfile
// 2nd custom cell
case 1:
let myInfo = tableView.dequeueReusableCellWithIdentifier("AlbumCell") as! AlbumTableViewCell
return myInfo
// 3rd Custom Cell
default:
let cell = tableView.dequeueReusableCellWithIdentifier("TravelBookCell") as! TravelBookTableViewCell
cell.travelBookImage.image = UIImage(named: tableData[indexPath.row])
cell.travelBookTitle.text = tableData[indexPath.row]
return cell
}
}