似乎无法弄清楚为什么我会收到此错误。
我在下面附加了两段代码,非常感谢您的帮助
private func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: IndexPath) -> UITableViewCell {
var cell = self.tableView.dequeueReusableCellWithIdentifier("postCell", forIndexPath: indexPath) as! PostTableViewCell <--- error is with this line
let post = self.posts![indexPath.row]
let user = post["user"] as? PFUser
let caption = post["caption"] as! String?
if let photo = post["media"] {
let imagePFFIle = photo as! PFFile
imagePFFIle.getDataInBackground(block: {(imageData: Data?, error: Error?) -> Void in
if error == nil {
if let imageData = imageData {
let image = UIImage(data:imageData)
cell.photoView.image = image
cell.usernameLabel.text = user?.username
cell.usernameLabel2.text = user?.username
cell.captionLabel.text = caption
}
}
})
}
//print("Image exists - Home View Controller")
//print("\(posts!.count)")
return cell
}
Main.storyboard中的类
<tableView clipsSubviews="YES" contentMode="scaleToFill" fixedFrame="YES" restorationIdentifier="" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" reuseIdentifier="postCell" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="28" sectionFooterHeight="28" translatesAutoresizingMaskIntoConstraints="NO" id="QKL-F5-RQ0" customClass="PostTableViewCell">
<rect key="frame" x="0.0" y="71" width="375" height="596"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</tableView>