来自苹果的Core Animation Programming Guide,清单4:
...
// create the filter and set its default values
CIFilter *filter = [CIFilter filterWithName:@"CIBloom"];
[filter setDefaults];
[filter setValue:[NSNumber numberWithFloat:5.0] forKey:@"inputRadius"];
// name the filter so we can use the keypath to animate the inputIntensity
// attribute of the filter
[filter setName:@"pulseFilter"];
...在[filter setName...行I得到一个"No visible @interface for 'CIFilter‘声明选择器'setName:’“
我看到过滤器是使用filterWithName初始化器创建的,所以我怀疑它的名称是只读的。但是为什么这个例子会出现在苹果的代码中,以及我发现的许多其他例子中呢?
发布于 2012-08-05 05:12:19
可写name属性是通过只存在于Mac上的Core Animation additions类别添加的。请参阅CIFilter Animatable Properties subsection
核心动画向核心图像的CIFilter类添加了以下可设置动画的属性。有关详细信息,请参见CIFilter核心动画添加。这些属性仅在OS X上可用。
iOS上的CIFilter确实有一个-name方法,但这只用于对过滤器名称的只读访问,并且没有匹配的设置器。
你上面链接到的核心动画编程指南的那一部分是从原始的苹果版本的指南复制和粘贴的,应该修改一下,因为它不完全适用于iOS。
发布于 2012-08-05 01:53:40
坦率地说,我从未见过试图更改CIFilter名称的示例-从filterWithName获得的是一个高度专门化的对象。如果您查看类文档,您会发现它显示了一个返回名称的方法" name“,但没有readwrite属性。
如果您需要对象的密钥路径,则将其存储在您的类的属性中,然后可以通过setValue:...forKeyPath:@“myClass.myIvar。”
编辑:完全清楚地说:
Core Image was added in iOS 5. Also the statement in the answer is not correct. Look in the CIFilter class description "name
The name of the filter.
- (NSString *)name
Return Value
A string that holds the name of the filter.
Availability
Available in iOS 5.0 and later.
Declared In
CIFilter.h在CIFilter.h中查找iOS5.1:
"- (NSString*)name __OSX_AVAILABLE_STARTING(__MAC_NA, __IPHONE_5_0);“
https://stackoverflow.com/questions/11810649
复制相似问题