我正在尝试访问一个导出,一个 imageView,它位于另一个类中。当我输入 socket 名称时,它会生成错误,因为 socket 位于另一个类中。如何访问另一个类中的 imageView 导出?
代码:
//Class I am trying to call the outlet in
override func viewDidLoad() {
super.viewDidLoad()
if photosAsset == nil {
//ERROR: Use of unresolved identifier: myImageView, since myImageView is in the class PhotoThumbnail
myImageView.image = ""
}
//Class with the oulet
class PhotoThumbnail: UICollectionViewCell {
@IBOutlet var myImageView : UIImageView!
}
最佳答案
创建 PhotoThumbnail 对象
var photoThumbnail = PhotoThumbnail()//没有任何初始化器
然后
照片缩略图.image
既然是collectionViewCell,就在cellforItemAtIndexPath方法中进行
关于ios - 访问另一个类中的 socket (Swift),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31396418/