नहीं कहा गया है मैंने UIViewController के अंदर एक टेबलव्यू डाला। लेकिन मेरा कोड काम नहीं कर रहा है। जब मैंने चेक किया तो मैंने पाया कि टेबलव्यू फ़ंक्शंस में से कोई भी नहीं कहा जाता है।स्विफ्ट - UIViewController के अंदर UITableView, UITableView फ़ंक्शंस को
class CustomViewController: UIViewController, UITableViewDataSource, UITableViewDelegate {
@IBOutlet weak var authorArticlesTableView: UITableView!
var authorid: Int!
var authorname: String!
var articles: [JSON]? = []
func loadArticles(){
let url = "http:here.com/" + String(authorid) + "/"
println(url)
Alamofire.request(.GET, url).responseJSON { (Request, response, json, error) -> Void in
if (json != nil){
var jsonObj = JSON(json!)
if let data = jsonObj["articles"].arrayValue as [JSON]?{
self.articles = data
self.authorArticlesTableView.reloadData()
}
}
}
}
override func viewDidLoad() {
super.viewDidLoad()
self.loadArticles()
println("viewDidLoad")
}
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
println("numberOfRowsInSection")
return self.articles?.count ?? 0
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
var cell = tableView.dequeueReusableCellWithIdentifier("CustomCell") as! CustomTableViewCell
cell.articles = self.articles?[indexPath.row]
println("cellForRowAtIndexPath")
return cell
}
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
performSegueWithIdentifier("WebSegue", sender: indexPath)
tableView.deselectRowAtIndexPath(indexPath, animated: true)
}
इसके लिए कोई समाधान?
धन्यवाद,
क्या आपने प्रतिनिधि और डेटा स्रोत सेट किया था? – Asaf