在不使用 QCView 和 QCPatchController 的情况下观察 Quartz Composition 的发布值

发布于 2024-10-23 12:14:16 字数 1000 浏览 0 评论 0原文

我一直在寻找一些控制 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文