tableView (swift)

class ViewController: UIViewController,UITableViewDelegate,UITableViewDataSource {

let ary = ["Dog","cat","Elephant","hen","money"]

@IBOutlet var tabV: UITableView!
override func viewDidLoad() {
super.viewDidLoad()

self.tabV.delegate=self
self.tabV.dataSource=self


}
public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int
{
return ary.count
}

public func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell
{
let cell = tabV.dequeueReusableCell(withIdentifier: "cell", for: indexPath ) as! homeTableViewCell


cell.label.text = ary[indexPath.row]
return cell
}
}
Previous
Next Post »