Could not cast value of type 'UITableViewCell' to '(AppName).(CustomCellName)'

前端 未结 12 1768
一生所求
一生所求 2020-12-02 23:03

I\'m currently trying to create a custom table view cell using xCode 6.3 swift 1.2. For some reason in the cellforRowAtIndexPath method, I just can\'t seem to set up my cell

12条回答
  •  难免孤独
    2020-12-02 23:19

    I had the same error. As obo2O states in his comment, his solution worked for me:

    1. Go to the Interface Builder
    2. Click on the relevant storyboard
    3. Click on the relevant cell within the tableview
    4. In the Utilities Panel (right side), click on the "Show the Identify Inspector" icon
    5. In the "Custom Class" section -> "Class" field, set the class to anything else and run the application. The application crashes, for classX cannot cast to classY
    6. In the "Custom Class" section -> "Class" field, set the class to the correct class and re-run.

提交回复
热议问题