w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
SWIFT TableView not loading text

Try this :

class ViewController: UIViewController, UITableViewDelegate,
MKMapViewDelegate, UIGestureRecognizerDelegate,UITableViewDataSource

then replace your function by copying this two functions by command + click on UITableViewDataSource:

func tableView(tableView: UITableView, numberOfRowsInSection
section: Int) -> Int{

}

and other one is :

func tableView(tableView: UITableView, cellForRowAtIndexPath
indexPath: NSIndexPath) -> UITableViewCell{

}  

and put all the code into this two function and try again becouse in your code this two functions are not getting called but by doing this your function will called and you have put all the required code into this function.

and also remove comment from

self.tableView!.dataSource = self

May be this can help you.

Edit For this Answer:

    func tableView(tableView: UITableView, cellForRowAtIndexPath
indexPath: NSIndexPath) -> UITableViewCell{

    var identifier : NSString = "Cell"

    var cell = tableView.dequeueReusableCellWithIdentifier(identifier) as?
UITableViewCell

    if !(cell != nil) {
        cell = UITableViewCell(style: UITableViewCellStyle.Value1,
reuseIdentifier: identifier)
    }
    cell?.textLabel?.text = "Hello World"
    return cell!
    }




© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.