班级不会出现

时间:2017-07-13 15:02:48

标签: ios swift xcode

我刚刚让这段代码工作了几天,现在它给了我一个错误:

  

Interface Builder文件中的未知类DraggableImage。

我试过清理文件,多次重启计算机和Xcode,但没有任何工作。我知道有这样的问题,但他们所说的一切都对我有用。此类不在下拉菜单中。它位于ViewDidLoad部分。

我的代码:

class DraggableImage : UIImageView {

    required init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
        self.isUserInteractionEnabled = true
    }

    override func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent?) {
        let touch = touches.first;
        let location = touch?.location(in: self.superview);
        if location != nil {
            self.frame.origin = CGPoint(x: location!.x-self.frame.size.width, y: location!.y-self.frame.size.height);
        }
    }
}

2 个答案:

答案 0 :(得分:1)

使你的模块变为current - {Your Project}但不是无 expected Module

答案 1 :(得分:0)

编辑:嗯...这可能不是你遇到的麻烦...如果是这样的话,我会删除这个答案。

在整个项目中将其作为文本字符串进行搜索。它应该显示如下:

enter image description here