[ad_1]
I come right here to ask for assist for a small drawback that’s occurring within the growth of this software.
I’ve little expertise with Swift, and I’m writing some code to be taught extra. I’ve this software that has within the preliminary display a set of buttons that redirects to completely different pages and options.
The button known as “Desk View (CH Cantons)” redirects to a brand new view, which accommodates a TableView that present us three issues:
- Canton emblem or coat of arms
- The Canton, as title : Ex: ZH – Zurich
- The world of particular canton
When a canton is chosen the applying ought to ahead to a brand new web page and present particulars about that specific canton, however this isn’t taking place regardless of my efforts to resolve the issue. Is TableView required to be within the Important View / Important Web page?
Bellow is the reference to the Navigation controller
The code that generates the Desk View
let cantonsData = ["AG - Aargau","BE - Bern","GE - Geneve","GR - Graubunden","JU - Jura","LU - Lucern","NE - Neuchâtel","SG - Sankt Gallen","TG - Thurgau","TI - Ticino","UR - Uri","VD - Vaud","VS - Valais","ZH - Zurich","AI - Appenzell n Innerrhoden","AR - Appenzell n Ausserrhoden","SH - Schaffhausen","BL - Basel n Landschaft","BS - Basel","SO - Solothurn","FR - Fribourg","ZG - Zug","GL - Glarus","NW - Nidwald","OW - Obwald", "SZ - Schwyz"]
let space = ["Area (km2): 1404 km2","Area (km2): 5,960 km2","Area (km2): 1,792 km2","Area (km2): 7,105 km2","Area (km2): 839 km2","Area (km2): 1,494 km2","Area (km2): 802 km2 ","Area (km2): 2031 km2","Area (km2): 992 km2","Area (km2): 2812 km2","Area (km2): 1077 km2","Area (km2): 3212 km2","Area (km2): 5224 km2","Area (km2): 1729 km2","Area (km2): 172 km2","Area (km2): 243 km2","Area (km2): 298 km2","Area (km2): 518 km2","Area (km2): 37 km2","Area (km2): 790 km2","FR - Fribourg","ZG - Zug","GL - Glarus","NW - Nidwald","OW - Obwald", "SZ - Schwyz"]
override var modalPresentationStyle: UIModalPresentationStyle {
get { .fullScreen }
set { assertionFailure("Shouldnt change that 😠") }
}
override func viewDidLoad() {
//tremendous.viewDidLoad()
// Do any further setup after loading the view, sometimes from a nib.
self.title = "CH Cantons / CH Kantons"
tableView.dataSource = self
tableView.delegate = self
let nibName = UINib(nibName: "TableViewCell", bundle: nil)
tableView.register(nibName, forCellReuseIdentifier: "tableViewCell")
}
func tableView(_ tableView: UITableView, numberOfRowsInSection part: Int) -> Int {
return cantonsData.rely
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "tableViewCell", for: indexPath) as! TableViewCell
cell.commonInit("CH-(indexPath.merchandise+1)", title: cantonsData[indexPath.item], sub: space[indexPath.item])
return cell
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return 180
}
operate liable for opening new web page when a cell of desk view is chosen
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let storyboard = UIStoryboard(identify: "TableViewCH", bundle: nil)
if let vc = storyboard.instantiateViewController(withIdentifier: "DetailViewController") as? DetailViewController{
vc.img = UIImage(named: cantonsData[indexPath.item])!
vc.canton = cantonsData[indexPath.row]
self.navigationController?.pushViewController(vc, animated: true)
}
}
I’ve tried one other one however can not clear up the issue
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: IndexPath) {
let cell = tableView.cellForRow(at: indexPath)
tableView.deselectRow(at: indexPath, animated: true)
performSegue(withIdentifier: "mySegue", sender: cell)
}
[ad_2]


