Так что я пытаюсь иметь 3 разных сегмента с тремя ячейками секций в виде таблицы. Я получаю начальное табличное представление для заполнения пользовательскими данными ячеек, но имею проблемы с настройкой каждой ячейки для перехода к каждому соответствующему новому ViewController ... Так что 3 ячейки с 3 различными сегментами - это то, что я хочу ... ценю помощь!3 tablesView Разделы с пользовательскими ячейками Segues swift
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
}
}
достаточно легкий, спасибо! – user3708224