iOS9:从cellForRowAtIndexPath返回之前的UITableViewCell构建

时间:2015-11-03 05:42:41

标签: ios swift uitableview ios9

我的代码仍然可以在iOS8中完美运行,但在iOS9中,单元格在cellForRowAtIndexPath返回UITableViewCell O.o之前以某种方式构建。

// in my TableView.swift file:
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {

    // It seems the cell.swift file is run here, breaking at layoutSubViews (below)
    let cell = tableView.dequeueReusableCellWithIdentifier("cell", forIndexPath: indexPath) as! QSMyCellNEW

    cell.delegate = self
    cell.QJoinObject = myQJoinObjects[indexPath.row] as! PFObject

    print(cell.QJoinObject) // all data present

    return cell
}



// in my tableViewCell.swift file:
class QSMyCellNEW: UITableViewCell {

var QJoinObject: PFObject!
}
.
.
.
override func layoutSubviews() {
    super.layoutSubviews()

    print(QJoinObject) // breaks - unwraps nil optional
}

0 个答案:

没有答案