我有一个OS X应用程序,我想全屏运行。我的搜索引出了两个解决方案:
collectionBehavior
的{{1}}属性和NSWindow
的{{1}}功能。我的应用程序使用其中任何一种方法进入全屏,但使用- enterFullScreenMode:withOptions:
的{{1}}设置为NSView
并使用NSWindow
进行切换时,我会得到很多输出中的错误:
collectionBehavior
我尝试在NSWindowCollectionBehaviorFullScreenPrimary
上放置一个符号断点,但我无法从反汇编中收集任何有用的东西。
大多数- toggleFullScreen:nil
的在线引用来自iOS,而不是OSX,其中解决方案是iOS中的错误或应用Feb 2 14:37:02 ***REDACTED***[10137] <Error>: CGContextSaveGState: invalid context 0x0. Backtrace:
<-[NSFrameView drawWindowBackgroundRect:]+48>
<-[NSThemeFrame drawWindowBackgroundRect:]+129>
<-[NSFrameView drawThemeContentFill:inView:]+290>
<-[NSFrameView drawRect:]+1156>
<-[NSThemeFrame drawRect:]+280>
<-[NSView _drawRect:clip:]+3626>
<-[NSView _recursiveDisplayAllDirtyWithLockFocus:visRect:]+1873>
<-[NSView _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:]+838>
<-[NSThemeFrame _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:]+334>
<-[NSView _displayRectIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:]+2449>
<-[NSView displayIfNeeded]+1950>
<-[NSWindow displayIfNeeded]+232>
<___NSWindowGetDisplayCycleObserver_block_invoke6367+476>
<__37+[NSDisplayCycle currentDisplayCycle]_block_invoke+738>
<_ZN2CA11Transaction19run_commit_handlersE18CATransactionPhase+85>
<_ZN2CA7Context18commit_transactionEPNS_11TransactionE+160>
<_ZN2CA11Transaction6commitEv+508>
<_ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv+71>
<__CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__+23>
<__CFRunLoopDoObservers+391>
<__CFRunLoopRun+1178>
<CFRunLoopRunSpecific+296>
<RunCurrentEventLoopInMode+235>
<ReceiveNextEventCommon+432>
<_BlockUntilNextEventMatchingListInModeWithFilter+71>
<_DPSNextEvent+1067>
<-[NSApplication _nextEventMatchingEventMask:untilDate:inMode:dequeue:]+454>
<-[NSApplication run]+682>
<F***REDACTED***_main+206>
<_ZN7***REDACTED***RunAppEiPPcPNS_11ApplicationE+745>
<main+104>
Feb 2 14:37:02 ***REDACTED***[10137] <Error>: CGContextSetFillColorWithColor: invalid context 0x0. Backtrace:
<__40-[NSAppearance _setCustomColor:setType:]_block_invoke+72>
<-[NSCompositeAppearance _callCoreUIWithBlock:]+183>
<-[NSAppearance _setCustomColor:setType:]+138>
<-[NSDynamicSystemColor set]+60>
<NSDrawWindowBackground+175>
<-[NSFrameView drawWindowBackgroundRect:]+48>
<-[NSThemeFrame drawWindowBackgroundRect:]+129>
[OMITTED FOR BREVITY]
Feb 2 14:37:02 ***REDACTED***[10137] <Error>: CGContextSetStrokeColorWithColor: invalid context 0x0. Backtrace: [CALLSTACK OMITTED FOR BREVITY]
Feb 2 14:37:02 ***REDACTED***[10137] <Error>: CGContextSetAlpha: invalid context 0x0. Backtrace: [CALLSTACK OMITTED FOR BREVITY]
Feb 2 14:37:02 ***REDACTED***[10137] <Error>: CGContextGetAllowsDithering: invalid context 0x0. Backtrace: [CALLSTACK OMITTED FOR BREVITY]
Feb 2 14:37:02 ***REDACTED***[10137] <Error>: CGContextSetAllowsDithering: invalid context 0x0. Backtrace: [CALLSTACK OMITTED FOR BREVITY]
Feb 2 14:37:02 ***REDACTED***[10137] <Error>: CGContextGetCompositeOperation: invalid context 0x0. Backtrace: [CALLSTACK OMITTED FOR BREVITY]
Feb 2 14:37:02 ***REDACTED***[10137] <Error>: CGContextSetCompositeOperation: invalid context 0x0. Backtrace: [CALLSTACK OMITTED FOR BREVITY]
Feb 2 14:37:02 ***REDACTED***[10137] <Error>: CGContextFillRects: invalid context 0x0. Backtrace: [CALLSTACK OMITTED FOR BREVITY]
Feb 2 14:37:02 ***REDACTED***[10137] <Error>: CGContextSetCompositeOperation: invalid context 0x0. Backtrace: [CALLSTACK OMITTED FOR BREVITY]
Feb 2 14:37:02 ***REDACTED***[10137] <Error>: CGContextSetAllowsDithering: invalid context 0x0. Backtrace: [CALLSTACK OMITTED FOR BREVITY]
Feb 2 14:37:02 ***REDACTED***[10137] <Error>: CGContextRestoreGState: invalid context 0x0. Backtrace: [CALLSTACK OMITTED FOR BREVITY]
Feb 2 14:37:02 ***REDACTED***[10137] <Error>: CGContextSetFillColorWithColor: invalid context 0x0. Backtrace: [CALLSTACK OMITTED FOR BREVITY]
Feb 2 14:37:02 ***REDACTED***[10137] <Error>: CGContextSetStrokeColorWithColor: invalid context 0x0. Backtrace: [CALLSTACK OMITTED FOR BREVITY]
Feb 2 14:37:02 ***REDACTED***[10137] <Error>: CGContextGetCompositeOperation: invalid context 0x0. Backtrace: [CALLSTACK OMITTED FOR BREVITY]
Feb 2 14:37:02 ***REDACTED***[10137] <Error>: CGContextSetCompositeOperation: invalid context 0x0. Backtrace: [CALLSTACK OMITTED FOR BREVITY]
Feb 2 14:37:02 ***REDACTED***[10137] <Error>: CGContextFillRects: invalid context 0x0. Backtrace: [CALLSTACK OMITTED FOR BREVITY]
Feb 2 14:37:02 ***REDACTED***[10137] <Error>: CGContextSetCompositeOperation: invalid context 0x0. Backtrace: [CALLSTACK OMITTED FOR BREVITY]
中缺少CGPostError
条目,这没有帮助在我的情况下。
我尝试使用invalid context 0x0
禁用菜单栏和停靠栏,但这并没有改变任何内容。
如果我在UIViewControllerBasedStatusBarAppearance
上使用Info.plist
,则没有错误,但我更喜欢保留使用NSApplicationPresentationOptions
时获得的默认全屏切换动画。
切换到- enterFullScreenMode:withOptions:
会导致错误消失,这让我相信问题可能与我的应用后面自动绘制的“停电”矩形有关。 (我记得在某个地方读过一些东西。)
什么是试图吸引无效的上下文,我怎样才能给它一个有效的上下文?
我NSView
的相关应用初始化:
- toggleFullScreen:
感谢。