【问题标题】:Swift not accepting text property?斯威夫特不接受文本属性?
【发布时间】:2015-05-22 09:47:47
【问题描述】:

我正在使用 UITableView,但 text 属性存在一些问题。我已经正确地宣布了一切,我确信一切都是正确的。这是我的错误代码:

func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell{
    let cell : UITableViewCell = UITableViewCell(style: UITableViewCellStyle.Subtitle, reuseIdentifier: "Test")
    cell.text = taskAdder.tasks[indexPath.row].name
    return cell
}

错误就行了:

cell.text = taskAdder.tasks[indexPath.row].name

上面写着:

'text' is unavailable: APIs depreciated as of iOS 7 and earlier are unavailable in Swift.

我不确定此错误的含义或如何修复它。

任何意见和建议将不胜感激。

提前致谢。

【问题讨论】:

    标签: function uitableview swift text return


    【解决方案1】:

    cell.text 自 iOS 7 起已弃用。 使用cell.textLabel.text

    查看更多信息: https://developer.apple.com/library/prerelease/ios/documentation/UIKit/Reference/UITableViewCell_Class/index.html

    【讨论】:

      【解决方案2】:

      错误提示“UITableViewCell”上没有文本方法

      你试过“cell.textLabel”吗,因为textLabel,detailTextLabel是用来设置UITableViewCell中的文字

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2014-08-10
        • 2017-07-22
        • 2017-03-24
        • 1970-01-01
        • 2016-02-08
        • 2017-11-13
        • 2015-08-19
        • 2014-09-11
        相关资源
        最近更新 更多