使用未声明的类型'PostTableViewCell'

问题描述 投票:0回答:1

似乎无法弄清楚为什么我收到这个错误。

我在下面附上了两段代码,非常感谢任何帮助

    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>
swift xcode viewcontroller
1个回答
0
投票

PostTableViewCell可能不是正确目标的一部分。在导航器中选择文件,打开正确的痛苦并选择File Inspector。确保选中主目标。见下面的例子:enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.