相关疑难解决方法(0)

无法将"UITableViewCell"类型的值转换为"AppName.CustomCellName"

我正在尝试创建一个自动扩展的自定义单元格.我正在使用这个github示例:https://github.com/rcdilorenzo/Cell-Expander

这一行给出了运行时错误SIGABRT:

override func tableView(tableView: UITableView, willDisplayCell cell: UITableViewCell, forRowAtIndexPath indexPath: NSIndexPath) {
    (cell as! EventTableViewCell).watchFrameChanges()
    //Could not cast value of type 'UITableViewCell' (0x105aa1b80) to 'AppName.EventTableViewCell' (0x104287fe0).
}
Run Code Online (Sandbox Code Playgroud)

我也检查了这篇文章的答案,接着是三个步骤,但没有运气: 无法将'UITableViewCell'类型的值转换为'(AppName).(CustomCellName)'

我的自定义单元类看起来像这样:

import UIKit

class EventTableViewCell : UITableViewCell {
...
}
Run Code Online (Sandbox Code Playgroud)

的cellForRowAtIndexPath:

override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
    let cell = tableView.dequeueReusableCellWithIdentifier( "eventCell", forIndexPath: indexPath)

    let date = self.eventArray[indexPath.row].startTime
    let calendar = NSCalendar.currentCalendar()
    let minutes = calendar.component(NSCalendarUnit.Minute, fromDate: date)
    var minutesString: String
    if (minutes …
Run Code Online (Sandbox Code Playgroud)

xcode uitableview ios swift2

5
推荐指数
1
解决办法
1万
查看次数

标签 统计

ios ×1

swift2 ×1

uitableview ×1

xcode ×1