我有一个UITableView
通过远程JSON
文件填充问题。我有两个功能:Swift tableView ambigious
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return newsdata.count
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as! NewsTableViewCell
let nachricht = newsdata[indexPath.row]
cell.NewsHeadline.text = nachricht.newstitel
return cell
}
设置和运行,并与连接到另一个视图控制器与UIWebView
ID为“ShowNewsDetail” Segue公司。然而,连接两个控制器中的代码不工作:
override func prepareForSegue(segue: UIStoryboardSegue,
sender: AnyObject?) {
if segue.identifier == "ShowNewsDetails" {
let detailViewController = segue.destinationViewController
as! NewsDetailViewController
let myIndexPath = self.tableView.indexPathForSelectedRow()
let row = myIndexPath?.row
detailViewController.webSite = newsdata[row!]
}
}
的Xcode 7.1报告“不明确的参照构件‘的tableView’”和点之前这两个函数为“候选”。我不知道如何挑选候选人或解决这个令人讨厌的错误。
什么是两个函数在Xcode指向的错误之前? 'numberOfRowsInSection'“&”'cellForRowAtIndexPath'“函数? –
你初始化了什么类?它是一个VIewController还是tableView控制器?如果是这样的话,请参阅此链接:http://stackoverflow.com/questions/30028129/how-to -fix-nib-but-didnt-get-a-uitableview-error/33484728?noredirect = 1#comment54770542_33484728。我猜你没有初始化tableView。 – lukaivicev
lukeslvi答案导致我的错误。填满表格,从表格视图到控制器的出口缺失 – Matt