我编写了一个 corevideo 应用程序,它有一个带有单个内容视图的窗口。
窗口按预期调整大小。我添加了代码以使其接受全屏事件,窗口按预期执行和工作,停靠栏和菜单自动隐藏并在鼠标悬停在预期位置时出现。
但是,当我退出全屏模式时,我在 AppKit 中遇到断言失败,NSWindow_FullScreen.m
我在全屏文档中的任何地方都找不到,也找不到搜索谷歌的错误消息。我尝试为NSWindowDidExitFullScreen
通知添加观察者,但断言仍然存在。我希望有人能帮忙。
2020-05-10 10:01:16.812 a.out[45616:2858300] *** Assertion failure in -[NSWindow _didExitFullScreen], /BuildRoot/Library/Caches/com.apple.xbs/Sources/AppKit/AppKit-1561.61.100/FullScreen.subproj/NSWindow_FullScreen.m:469
2020-05-10 10:01:16.812 a.out[45616:2858300] content controller was not cleaned up properly
我不确定它指的是什么内容控制器,我尝试添加一个窗口控制器但它仍然失败,我不确定需要清理什么,因为我的应用程序仍在运行并在窗口中呈现.
这是我展示问题的最小应用程序。编译:gcc -framework AppKit example.m
#import <AppKit/AppKit.h>
int main (int argc, char **argv)
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
[NSApplication sharedApplication];
[NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
NSUInteger windowStyle = NSWindowStyleMaskTitled | NSWindowStyleMaskClosable | NSWindowStyleMaskResizable;
NSRect wr = NSMakeRect(0,0,640,480);
NSWindow * window = [[NSWindow alloc] initWithContentRect:wr
styleMask:windowStyle
backing:NSBackingStoreBuffered
defer:NO];
[window autorelease];
NSWindowCollectionBehavior behavior = [window collectionBehavior];
behavior |= NSWindowCollectionBehaviorFullScreenPrimary;
[window setCollectionBehavior:behavior];
[[NSNotificationCenter defaultCenter]
addObserver:NSApp
selector:@selector(terminate:)
name:NSWindowWillCloseNotification
object:nil];
[window orderFrontRegardless];
[NSApp run];
[pool drain];
return 0;
}