I am getting this error: *** Assertion failure in -[UITableView dequeueReusableCellWithIdentifier:forIndexPath:] with static cells.
My code is in Swift (the reuse identifiers are strings set as constants in the file):
... private let topTableViewCellIdentifier = "topTableViewCell" private let bottomTableViewCellIdentifier = "bottomTableViewCell" ...
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let reuseIdentifier = (indexPath.section == 0) ? topTableViewCellIdentifier : bottomTableViewCellIdentifier
let cell = tableView.dequeueReusableCellWithIdentifier(reuseIdentifier, forIndexPath: indexPath)
return cell
}
I have searched stack overflow for this error, and found a bunch of answers all basically saying the same thing: make sure the reuse identifier is the same as the one for the cell in the storyboard.
However, in my case, it is.
I have confirmed this repeatedly, and have cut and pasted from one to the other repeatedly in order to ensure this is the case. Xcode clearly indicates that the correct value is being set. I have cleaned. I have even restarted. I have done everything I can think of, and it does not see the cells in the storyboard. They are set as static, and The correct class is being set in the inspector (though that should be clear by the fact that it gets the correct value)
Any thoughts or assistance would be appreciated. I am using El Capitan and Xcode 7.
If you are attempting to use a static layout for a table view, you typically do not implement tableView:cellForRowAtIndexPath:
, the UITableViewController
does this for you. It is invalid to call the dequeueReusableCellWithIdentifier:forIndexPath:
method for a statically configured UITableView
(as the error indicates).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.