我进行了子类UITableViewCell
化,并在其中- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
设置了一些实例变量,如下所示:
_image = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"image.png"]]
我没有使用任何访问器,因为 Apple 建议不要在 和 中使用访问init
器dealloc
。
到目前为止,一切都很好。我的问题是在我设置了要为图像设置的 _imageuserInteractionEnabled
之后YES
。我应该使用 getter 还是应该直接使用 ivar?
self.image.userInteractionEnabled = YES;
或者
_image.userInteractionEnabled = YES;
首选使用哪种风格?