Ich bin neu in iOS und begann mit einigen Tutorials. Aber wenn ich versuche, den Inhalt in tableview
anzuzeigen, wird es nicht angezeigt. Ich habe alles so gemacht wie in diesem Tutorial. Aber ich konnte meinen contentnt immer noch nicht in meiner Tabellenansicht anzeigen.Daten werden nicht in der Tabellenansicht angezeigt
Hier mein tutoial Link: My link
Hier mein Code:
import UIKit
import Alamofire
class ViewController: UIViewController,UITableViewDelegate,UITableViewDataSource {
@IBOutlet weak var tableView: UITableView!
var nameArray = [AnyObject]()
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
Alamofire.request("http://thecodeeasy.com/test/swiftjson.json").responseJSON { response in
let result = response.result
if let dict = result.value as? Dictionary<String,AnyObject>{
if let mainDict = dict["actors"] {
self.nameArray = mainDict as! [AnyObject]
self.tableView.reloadData()
}
}
}
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int
{
return nameArray.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell
{
let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath as IndexPath) as? CustomTableViewCell
let title = nameArray[indexPath.row]["title"]
cell?.ContentName.text = title as? String
return cell!
}
}
ist es in swift 3.0? –
JA ........... –
Schreiben Sie Alamofire.request ("http://thecodeeasy.com/test/swiftjson.json") in viewdidappear anstelle von viewdidload –