I have recently started Xcode and I following one example I did a 'didSelectRowAt' to go from my decided image to the View I want. That's good and all, but now I want to go to Different storyboards and not use my recycled View. I have been pounding this for a couple of days and I really can't seem to figure out how.
This is my VC.swift
class CategoriesVC: UIViewController, UITableViewDataSource, UITableViewDelegate {
@IBOutlet weak var categoryTable: UITableView!
override func viewDidLoad() {
super.viewDidLoad()
categoryTable.dataSource = self
categoryTable.delegate = self
}
}
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let category = DataService.instance.getCategories()[indexPath.row]
performSegue(withIdentifier: "ProductsVC", sender: category)
performSegue(withIdentifier: kitListIdentifier, sender: category)
}
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if let productsVC = segue.destination as? ProductsVC {
let barBtn = UIBarButtonItem()
barBtn.title = ""
navigationItem.backBarButtonItem = barBtn
assert(sender as? Category != nil)
productsVC.initProducts(category: sender as! Category)
}
}
}
And this is my storyboard.
Aas you see I want to go to KitList based on the image position I choose from the first VC. In this case, position 0.
Could you give me some help?
Thanks
You can try
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let category = DataService.instance.getCategories()[indexPath.row]
if(indexPath.row == 0)
{
performSegue(withIdentifier: kitListIdentifier, sender: category)
}
else
{
performSegue(withIdentifier: "ProductsVC", sender: category)
}
}