ios - 访问另一个类中的 socket (Swift)

标签 ios swift class

我正在尝试访问一个导出,一个 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/

相关文章:

ios - Swift:IOS7 设备上的核心数据 -> 第二个实体上的 entityForName 为 nil

iphone - 将图层阴影裁剪为宽度而不是高度?

arrays - Swift 字典数组包含一个 double 值,保存到用户默认值添加小数位

iOS Swift - 修改一个数组会修改另一个数组

c++ - 在 g++ 上无效使用不完整类型

ios - NSNotificationCenter 的帖子导致 "EXC_BAD_ACCESS"异常

ios - 如何使用 .whereKey() 函数访问 Parse 中另一个类中的指针列?

Swift:将 Any 转换为协议(protocol)对象数组

c++ - 动态链接列表 RPG 库存程序 - 帮助(如何链接到类?)

class - 使用 "Coffee Script Class"而不是方法作为 Angular JS ng-controller