В UITableViewCell
название песни, которая должна быть показана, отображается с надписью «Label» из раскадровки. Код контроллера:UITableViewCell с надписью «Label» повторно
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("AudioCell") as AudioCell
var mp3file: AnyObject = mp3sPaths[indexPath.row]
cell.textLabel?.text = mp3file.lastPathComponent
cell.playIcon.text = "▶️"
return cell
}
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
var mp3file = mp3sPaths[indexPath.row] as NSString
var mp3URL: NSURL = NSURL.fileURLWithPath(mp3file)!
var error: NSError?
audioPlayer?.stop()
audioPlayer = AVAudioPlayer(contentsOfURL: mp3URL, error: &error)
audioPlayer?.play()
if let cell = tableView.cellForRowAtIndexPath(indexPath) as? AudioCell {
cell.playIcon.text = "◾️"
}
}
А код класса AudioCell: класс AudioCell: UITableViewCell {
@IBOutlet weak var playIcon: UILabel!
@IBOutlet weak var titleLabel: UILabel!
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
}
override func setSelected(selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
// Configure the view for the selected state
}
скриншот приложения является there:
Do у вас есть ярлык в раскадровке? – gabbler
В вашем контроллере вы ссылаетесь на textLabel? но в вашей камере это titleLabel. Зачем? –