i am pretty new to ios development. I have a table view with 2 Sections
TableView:
import UIKit
class ViewController: UIViewController,UITableViewDataSource,UITableViewDelegate{
var people = ["ABC","PQR","LMN"]
var languages = ["Android","Java","C++",".Net"]
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
func numberOfSectionsInTableView(tableView: UITableView) -> Int {
return 2
}
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
if section==0
{return people.count}
else
{return languages.count
}
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as UITableViewCell
if indexPath.section==0{
cell.textLabel?.text = people[indexPath.row]
}
else{
cell.textLabel?.text = languages[indexPath.row]
}
return cell
}
func tableView(tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
if section==0{
title="Names"
}
else{
title="Languages"
}
return title
}
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
tableView.deselectRowAtIndexPath(indexPath, animated: true)
}
}
I want make each item in the table view clickable. That is when an item from the table view is clicked a new corresponding table view opens. Can someone help me with it ?