我得到一个无法识别的选择器异常,试图在 a 上设置 alpha UIImageView
,但我不明白为什么这应该看到 aUIImageView
继承自UIView
并且alpha
是它的属性。
@property (strong, nonatomic) IBOutlet UIImageView *pulldownTab;
...
self.pulldownTab.alpha = 1.0;
2013-05-21 07:33:32.964 TestControl[655:907] -[__NSCFNumber setAlpha:]: unrecognized selector sent to instance 0x1e587fa0
** 更新 ** 故事的寓意 - 已解决。小心键值编码,之前调用了这个函数
- (void) fadeToAlphaValue: (double) alpha forKeyPath: (NSString*) keyPath
{
NSNumber* number = [NSNumber numberWithDouble:alpha];
[UIView animateWithDuration:kFadeAnimationDuration
animations:^ {
[self setValue:number forKeyPath:keyPath];
}];
}
[self fadeToAlphaValue:0.0 forKeyPath:@"self.pulldownTab"];