1

我正在编写 QTMovieView 的功能。我想双击 QTMovieView 使其退出全屏模式。QTMovieView 由 AppController.m 控制,我在 AppController 中编写了退出全屏模式功能。因为我想捕获双击 QTMovieView 的事件。所以我必须重写 mouseDown 事件。Override函数写在“QTMovieView+TFOverrideDrag.h”

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");
}

并且此功能成功覆盖。但 exitFullScreen 功能失败。我该如何解决?谢谢

更新

应用控制器.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

应用控制器.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
4

2 回答 2

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");
}    

关键是“超级”。

于 2013-01-09T02:36:33.073 回答
0

你确定AppController声明一个类方法+(void)exitFullScreen:吗?如果不是,那么您将需要将您的实例方法更改为类方法(使用 a+而不是 a -)或子类化QTMovieView该类并将实例传递AppController给实例。

于 2013-01-02T19:04:34.720 回答