无法在 table @masterViewController 中显示 url
unable to display urls in table @ masterViewController
我无法将 masterViewController 中的代码编译为
我收到错误 UITableView
没有名为 textLabel
的成员
var urls = [NSURL(string: "http://trialwebsite.ucoz.com/GurujiHymns/02_BIGDI_MERI_TAQDIR_KO_Singer_Masoom_Thakur.mp3")!,NSURL(string: "http://trialwebsite.ucoz.com/GurujiHymns/02_BIGDI_MERI_TAQDIR_KO_Singer_Masoom_Thakur.mp3")!,NSURL(string: "http://trialwebsite.ucoz.com/GurujiHymns/03_GURU_JI_TERI_REHMAT_Singer_Sada_Thakur.mp3")!]
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as! UITableViewCell
let object = objects[indexPath.row] as! NSDate
cell.textLabe!.text = NSURL(string: urls)[indexPath.row] // error UITableView does not have member named textLabel
return cell
}
你写的
cell.textLabe!.text
你必须写
cell.textLabel!.text
在 textLabel
中打印 url 字符串
cell.textLabel!.text = urls[indexPath.row].absoluteString!
试试这个
var urls = [NSURL(string: "http://trialwebsite.ucoz.com/GurujiHymns/02_BIGDI_MERI_TAQDIR_KO_Singer_Masoom_Thakur.mp3")!,NSURL(string: "http://trialwebsite.ucoz.com/GurujiHymns/02_BIGDI_MERI_TAQDIR_KO_Singer_Masoom_Thakur.mp3")!,NSURL(string: "http://trialwebsite.ucoz.com/GurujiHymns/03_GURU_JI_TERI_REHMAT_Singer_Sada_Thakur.mp3")!]
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as! UITableViewCell
let object = objects[indexPath.row] as! NSDate
cell.textLabe!.text = urls[indexPath.row]
return cell
}
我无法将 masterViewController 中的代码编译为
我收到错误 UITableView
没有名为 textLabel
var urls = [NSURL(string: "http://trialwebsite.ucoz.com/GurujiHymns/02_BIGDI_MERI_TAQDIR_KO_Singer_Masoom_Thakur.mp3")!,NSURL(string: "http://trialwebsite.ucoz.com/GurujiHymns/02_BIGDI_MERI_TAQDIR_KO_Singer_Masoom_Thakur.mp3")!,NSURL(string: "http://trialwebsite.ucoz.com/GurujiHymns/03_GURU_JI_TERI_REHMAT_Singer_Sada_Thakur.mp3")!]
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as! UITableViewCell
let object = objects[indexPath.row] as! NSDate
cell.textLabe!.text = NSURL(string: urls)[indexPath.row] // error UITableView does not have member named textLabel
return cell
}
你写的
cell.textLabe!.text
你必须写
cell.textLabel!.text
在 textLabel
中打印 url 字符串cell.textLabel!.text = urls[indexPath.row].absoluteString!
试试这个
var urls = [NSURL(string: "http://trialwebsite.ucoz.com/GurujiHymns/02_BIGDI_MERI_TAQDIR_KO_Singer_Masoom_Thakur.mp3")!,NSURL(string: "http://trialwebsite.ucoz.com/GurujiHymns/02_BIGDI_MERI_TAQDIR_KO_Singer_Masoom_Thakur.mp3")!,NSURL(string: "http://trialwebsite.ucoz.com/GurujiHymns/03_GURU_JI_TERI_REHMAT_Singer_Sada_Thakur.mp3")!]
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as! UITableViewCell
let object = objects[indexPath.row] as! NSDate
cell.textLabe!.text = urls[indexPath.row]
return cell
}