2013-01-02 4 views
1

QTMovieView의 함수를 작성하고 있습니다. 전체 화면 모드를 종료하려면 QTMovieView를 두 번 클릭하고 싶습니다. QTMovieView는 AppController.m에 의한 제어이며 AppController에서 exit fullscreenmode 함수를 작성합니다. QTMovieView를 두 번 클릭하면 이벤트를 캡처하기 때문에. 그래서 mouseDown 이벤트를 오버라이드해야합니다. 재정의 기능은다른 클래스의 변수를 조작하는 방법

QTMovieView + TFOverrideDrag.m

#import "QTMovieView+TFOverrideDrag.h" 
#include "AppController.h" 


@implementation QTMovieView (TFOverrideDrag) 

- (void)mouseDown:(NSEvent *)theEvent 
{ 
    [self.superview becomeFirstResponder]; 
    NSInteger clickCount = [theEvent clickCount]; 
    if (2 == clickCount) { 
     [AppController exitFullScreen:self]; 

     NSLog(@"SS"); 
    } 
    NSLog(@"MDown"); 
} 

은 "QTMovieView + TFOverrideDrag.h"에서 작성하고 성공적으로이 기능을 재정의한다. 그러나 exitFullScreen 함수는 실패합니다. 어떻게 해결할 수 있습니까? 감사합니다

업데이트

AppController.h

#import <Cocoa/Cocoa.h> 
#import <Carbon/Carbon.h> 
#import <QTKit/QTKit.h> 

@interface AppController : NSDocument 
{ 
    QTMovie  *qtmovie; 
    QTMovieView *_movieView; 
} 

@property (assign) IBOutlet QTMovieView *movieView; 


- (IBAction)toggleFullscreen:(id)sender; 
+(IBAction)exitFullScreen:(id)sender; 

@end 

AppController.m

#import "AppController.h" 

@implementation AppController 
@synthesize movieView=_movieView; 


- (IBAction)toggleFullscreen:(id)sender 
{ 

    _movieView=_movieView; 
    NSDictionary *fullScreenOptions = [[NSDictionary dictionaryWithObject:[NSNumber  numberWithBool:YES]forKey:NSFullScreenModeSetting] retain]; 

    [_movieView enterFullScreenMode:[[NSScreen mainScreen] retain] withOptions:fullScreenOptions]; 

} 

+(void)exitFullScreen:(id)sender 
{ 
    _movieView=_movieView; 
    NSLog(@"exitFullscreen"); 

    NSDictionary *fullScreenOptions = [[NSDictionary dictionaryWithObject:[NSNumber numberWithBool:YES]forKey:NSFullScreenModeSetting] retain]; 
    [_movieView exitFullScreenModeWithOptions:fullScreenOptions]; 
} 
@end 
+1

카테고리를 통해 구현을 제공하지 않고 *'QTMovieView '를 * 서브 클래스해야합니다. – trojanfoe

+0

하지만 exitFullscreen을 어떻게 수행합니까? –

+0

.h와 .m 파일 모두에서'exitFullScreen' 코드를 게시 할 수 있습니까? – FreeAsInBeer

답변

0

당신이 AppController+(void)exitFullScreen: 같은 클래스 메소드를 선언 하시겠습니까? 그렇지 않다면, 당신은 클래스 메소드 (대신 -+를 사용)에 인스턴스 방법을 변경하거나 QTMovieView 클래스를 서브 클래스 인스턴스에 AppController의 인스턴스를 전달해야합니다 중 하나.

+0

AppController에서 + exitFullScreen을 선언해야합니다. 그리고 Object-C에 익숙하지 않아서 죄송합니다. QTMovieView 클래스를 서브 클래스 화하고 인스턴스에 AppController의 인스턴스를 전달하는 방법은 무엇입니까? –

0

문제가 해결되었습니다! 키가 "슈퍼"

- (void)mouseDown:(NSEvent *)theEvent 
{ 
    [self.superview becomeFirstResponder]; 
    NSInteger clickCount = [theEvent clickCount]; 
    if (2 == clickCount) { 
     NSDictionary *fullScreenOptions = [[NSDictionary dictionaryWithObject:[NSNumber  numberWithBool:YES]forKey:NSFullScreenModeSetting] retain]; 
     [super enterFullScreenMode:[[NSScreen mainScreen] retain] withOptions:fullScreenOptions]; 
     NSLog(@"SS"); 
    } 
    NSLog(@"MDown"); 
}  

이다 : 나는이에 의해 문제를 해결.

관련 문제