在不使用 QCView 和 QCPatchController 的情况下观察 Quartz Composition 的发布值
我一直在寻找一些控制 Quartz Composition 的方法,它作为从 NSView 继承的自定义视图的子层加载。
NSString * compositionPath = [[NSBundle mainBundle] pathForResource:@"Test" ofType:@"qtz"];
QCCompositionLayer *myQCCompositionLayer = [[QCCompositionLayer compositionLayerWithFile:compositionPath] retain];
// Borderless window with custom view
[[self.contentView layer] addSublayer: myQCCompositionLayer];
我手动发现,以下代码适用于设置发布的输入值:
[myQCCompositionLayer setValue:@"123" forInputKey:@"published_text_input"];
所以我试图找到观看发布的输出值的方法,我想知道观察者是否应该这样做。写的是这样的:
[myQCCompositionLayer addObserver:self forKeyPath:@"published_output_value" options:0 context:nil];
在同一个班级里这样写:
- (void) observeValueForKeyPath:(NSString*)keyPath ofObject:(id)object
change:(NSDictionary*)change context:(void*)context
{
NSLog(@"123");
}
但它不起作用。也许密钥路径不正确或者此代码根本不应该工作:)
那么有什么方法可以观察我的作文的已发布值吗?
感谢您的帮助。
I've been looking for some ways to control Quartz Composition, that is being loaded as a sublayer of a custom view inherited from NSView.
NSString * compositionPath = [[NSBundle mainBundle] pathForResource:@"Test" ofType:@"qtz"];
QCCompositionLayer *myQCCompositionLayer = [[QCCompositionLayer compositionLayerWithFile:compositionPath] retain];
// Borderless window with custom view
[[self.contentView layer] addSublayer: myQCCompositionLayer];
Manually i found out, that the following code works for setting published input values:
[myQCCompositionLayer setValue:@"123" forInputKey:@"published_text_input"];
So i was trying to find the way to watch published output values and i was wondering if observer should do it. Written something like this:
[myQCCompositionLayer addObserver:self forKeyPath:@"published_output_value" options:0 context:nil];
And this in the same class:
- (void) observeValueForKeyPath:(NSString*)keyPath ofObject:(id)object
change:(NSDictionary*)change context:(void*)context
{
NSLog(@"123");
}
But it doesn't work. Maybe keypath is incorrect or this code shouldn't work at all :)
So are there any ways to observe published values of my composition?
Thanks for help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论