swift - 使用未声明的类型“PostTableViewCell”
问题描述
似乎无法弄清楚为什么我会收到此错误。
我在下面附上了两段代码,非常感谢任何帮助
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>
解决方案
推荐阅读
- firebase - Firebase 云函数增加队列号
- javascript - 为什么配置文件是用 commonJS 编写的
- flutter - 如何在构建小部件中使用导航器进行重定向
- c - 无法在 Windows Server 2019 上加载库
- git - 无法推送到 bitbucket 403“身份验证失败”
- app-store - TestFlight“等待审核”
- javascript - 使用useEffect时的无限循环,数组格式化
- c - 创建我的外壳:在我的提示符中用“~”替换主目录。替换主目录子字符串的问题
- java - 单CPU机器的最佳GC线程数
- python - 为什么我在 AWS 服务中的 lambda 函数存在超时问题?