【发布时间】:2012-09-17 06:57:12
【问题描述】:
我搜索了所有类似的问题,但找不到答案。我对此完全感到困惑......我有一个扩展 UIImageView 的类。所以这是我的 .h 文件:
@interface Paper : UIImageView {
@public
CGFloat drag;
}
@property (nonatomic, assign) CGFloat drag;
@end
我在我的实现中正确地合成了drag。
现在,在我的 ViewController 中,我创建并初始化一个 Paper 对象,如下所示:
NSString *tempPath = [[NSBundle mainBundle] pathForResource:@"picture" ofType:@"png"];
UIImage *tempImage = [[UIImage alloc] initWithContentsOfFile:tempPath];
Paper *tempPaper = [[UIImageView alloc] initWithImage: tempImage];
对象是正确创建的,我稍后可以将它显示为子视图和所有爵士乐,但是当我尝试在上面使用如下行之后立即更改我的自定义属性时:
tempPaper.drag = 1.0;
或
[tempPaper setDrag:1.0];
我收到[UIImageView setDrag:]: unrecognized selector sent to instance 错误。我已经尝试了我找到的每一种不同的方法,但它不允许我为 Paper 类设置我的自定义属性(非 UIImageView 属性)的值。我错过了什么?我在这上面花了 2 个小时,这让我发疯了,我看不出有什么问题。
我也尝试在 Paper 的 initWithImage 方法中初始化 drag,但它也不起作用。
【问题讨论】:
标签: iphone ios ipad uiimageview selector