在Xcode 5.1.1中使用Quartz

时间:2014-08-24 19:26:00

标签: xcode cocoa interface-builder quartz-composer

我是Xcode的新手,试图为Quartz Composition创建一个独立的应用程序。

Xcode 5.1.1 Quartz Composer 4.6(151)

步骤取自this video

  1. 我创建了一个新的Cocoa应用程序。

  2. 在“界面”构建器中打开MainMenu.xib。

  3. 拖放" Quartz Composer View"进入新窗口。

  4. 加载成分,我选择一个空白成分(注意:这是用我的最终成分和空白成分测试的)

  5. 返回主项目屏幕 - > Linked Frameworks and Libraries - > Add Framework - > Quartz.frameworkQuartzCore.framework

  6. 构建,这就是我得到的。

    The document "MainMenu.xib" could not be opened. The operation couldn’t be completed. (com.apple.InterfaceBuilder error -1.)

  7. 奇怪的是我的 Quartz output shows up fine in my Interface Builder window,但我的应用无法构建或运行。

2 个答案:

答案 0 :(得分:0)

好的,我找到了解决方案。

我下载了Quartz Container Application并将我的作品构建到其中。

Follow the video tutorial here.

答案 1 :(得分:0)

这就是我以编程方式将Quartz Composer组合添加到XCode 5应用程序中的方式,以便QCC填充窗口并随之调整大小。

NSString *path = [[NSBundle mainBundle] pathForResource:@"NameOfQCComposition" ofType:@"qtz"];
NSView *superView = [self.displayWindow contentView];

qcView = [[QCView alloc] initWithFrame:superView.frame];
[superView addSubview:qcView];
[superView setTranslatesAutoresizingMaskIntoConstraints:YES];
[superView setAutoresizesSubviews:YES];
[qcView setAutoresizingMask:NSViewWidthSizable|NSViewHeightSizable];

[superView addConstraint:
 [NSLayoutConstraint constraintWithItem: qcView
                               attribute: NSLayoutAttributeWidth
                               relatedBy: NSLayoutRelationEqual
                                  toItem: superView
                               attribute: NSLayoutAttributeWidth
                              multiplier:1
                                constant:0]];

[superView addConstraint:
 [NSLayoutConstraint constraintWithItem: qcView
                              attribute: NSLayoutAttributeHeight
                              relatedBy: NSLayoutRelationEqual
                                 toItem: superView
                              attribute: NSLayoutAttributeHeight
                             multiplier:1
                               constant:0]];
[superView addConstraint:
 [NSLayoutConstraint constraintWithItem: qcView
                              attribute: NSLayoutAttributeCenterX
                              relatedBy: NSLayoutRelationEqual
                                 toItem: superView
                              attribute: NSLayoutAttributeCenterX
                             multiplier:1
                               constant:0]];
[superView addConstraint:
 [NSLayoutConstraint constraintWithItem: qcView
                              attribute: NSLayoutAttributeCenterY
                              relatedBy: NSLayoutRelationEqual
                                 toItem: superView
                              attribute: NSLayoutAttributeCenterY
                             multiplier:1
                               constant:0]];

[qcView unloadComposition];
[qcView loadCompositionFromFile:path];
[qcView setMaxRenderingFrameRate: 30.0];
[qcView startRendering];

if(![qcView loadCompositionFromFile:path])
{
    NSLog(@"******QC.qtz failed to load");
    [NSApp terminate:nil];
}
NSLog(@"******qc.qtz has been loaded!!!!");
相关问题