我有一个导入另一个类的类,我正在尝试访问此类的属性,但是我收到一个错误,告诉我该值没有成员。我该怎么办?
错误发生在self.cachedImageView
中lib的类:
#import "JSQPhotoMediaItem.h"
@interface JSQPhotoMediaItem ()
@property (strong, nonatomic) UIImageView *cachedImageView;
@end
@implementation JSQPhotoMediaItem
以及实施方法继续。
我的班级试图访问cachedImageView
override func mediaView() -> UIView? {
if !self.hasFile {
return nil
}
if self.cachedImageView == nil {
let size = self.mediaViewDisplaySize()
let imageView = UIImageView(frame: CGRect(x: 0, y: 0, width: size.width, height: size.height))
let lightGrayColor = UIColor.jsq_messageBubbleLightGray()
imageView.backgroundColor = UIColor.jsq_messageBubbleLightGray()
imageView.image = UIImage(named: "file_placeholder")?.jsq_imageMasked(with: lightGrayColor.jsq_colorByDarkeningColor(withValue: 0.4))
imageView.contentMode = UIViewContentMode.center
let RightMargin = CGFloat(10)
let BottomMargin = CGFloat(20)
self.label.frame = CGRect(x: 0, y: 0, width: imageView.frame.width / 2, height: 20)
let point = CGPoint(x: 1.5 * imageView.center.x - RightMargin, y: imageView.frame.height - BottomMargin)
self.label.center = imageView.convert(point, from: imageView.superview)
self.label.textColor = UIColor.lightGray
self.label.textAlignment = NSTextAlignment.right
self.label.font = UIFont(name: "Helvetica", size: 14.0)
imageView.addSubview(label)
JSQMessagesMediaViewBubbleImageMasker.applyBubbleImageMask(toMediaView: imageView, isOutgoing: self.appliesMediaViewMaskAsOutgoing)
self.cachedImageView = imageView
}
return self.cachedImageView
}
答案 0 :(得分:0)
原因是因为你在.m文件而不是.h文件中创建了属性。目标c中的.m文件是私有的。如果你想在课堂外公开和访问某些内容,请在.h文件中声明它。它肯定会起作用。如果这样做,请不要忘记接受答案。