나는 NSView를 연구 중이므로 스크린 세이버에서 촬영할 것이라고 생각했습니다. NSView에서 이미지를 표시하고 이미지를 렌더링 할 수 있었지만이 예제 코드를 수정하여 ScreenSaverView에 간단한 그림을 표시 할 수는 없습니다. 스노우 레오파드 (Snow Leopard)와 함께 작동코코아 hello world screensaver
http://www.mactech.com/articles/mactech/Vol.20/20.06/ScreenSaversInCocoa/
BTW 좋은 튜토리얼.
내가 잘못 뭐하는 거지 나는 단순히 내가이 닮은 무언가를 필요 이미지를 표시하는 생각...
?
//
// try_screensaverView.m
// try screensaver
//
#import "try_screensaverView.h"
@implementation try_screensaverView
- (id)initWithFrame:(NSRect)frame isPreview:(BOOL)isPreview
{
self = [super initWithFrame:frame isPreview:isPreview];
if (self) {
[self setAnimationTimeInterval:1]; //refresh once per sec
}
return self;
}
- (void)startAnimation
{
[super startAnimation];
NSString *path = [[NSBundle mainBundle] pathForResource:@"leaf" ofType:@"JPG" inDirectory:@""];
image = [[NSImage alloc] initWithContentsOfFile:path];
}
- (void)stopAnimation
{
[super stopAnimation];
}
- (void)drawRect:(NSRect)rect
{
[super drawRect:rect];
}
- (void)animateOneFrame
{
//////////////////////////////////////////////////////////
//load image and display This does not scale the image
NSRect bounds = [self bounds];
NSSize newSize;
newSize.width = bounds.size.width;
newSize.height = bounds.size.height;
[image setSize:newSize];
NSRect imageRect;
imageRect.origin = NSZeroPoint;
imageRect.size = [image size];
NSRect drawingRect = imageRect;
[image drawInRect:drawingRect fromRect:imageRect operation:NSCompositeSourceOver fraction:1];
}
- (BOOL)hasConfigureSheet
{
return NO;
}
- (NSWindow*)configureSheet
{
return nil;
}
@end
대신에 무엇을할까요? (BTW, 당신이 이미지를 유출하고있어.) (non-GC 용) 객체를 놓고 누설을 고치기 위해 ivar을 nil (GC 용)으로 설정하십시오. –