我怎样才能设置CG_CONTEXT_SHOW_BACKTRACE环境variables?
在我看来,我有三个button。 在viewDidLoad()中设置了cornerRadus后: button.layer.cornerRadius = 20
我在日志中得到以下错误信息:
<Error>: CGContextSaveGState: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable.
问题:
-
我怎样才能设置CG_CONTEXT_SHOW_BACKTRACE环境variables? - 或者我该如何解决这个警告?
好吧,我现在从消息中回溯。 这对我没有任何意义。 一些帮助,请…
Aug 7 14:27:00 <Error>: CGContextSaveGState: invalid context 0x0. Backtrace: <-[UIStatusBarItemView updateContentsAndWidth]+33> <-[UIStatusBarItemView initWithItem:data:actions:style:]+477> <+[UIStatusBarItemView createViewForItem:withData:actions:foregroundStyle:]+134> <-[UIStatusBarLayoutManager _createViewForItem:withData:actions:]+163> <-[UIStatusBarLayoutManager _prepareEnabledItemType:withEnabledItems:withData:actions:itemAppearing:itemDisappearing:]+36 <-[UIStatusBarLayoutManager prepareEnabledItems:withData:actions:]+92> <-[UIStatusBarForegroundView _setStatusBarData:actions:animated:]+797> <-[UIStatusBarForegroundView setStatusBarData:actions:animated:]+332> <__51-[UIStatusBar _prepareToSetStyle:animation:forced:]_block_invoke+360> <+[UIView(Animation) performWithoutAnimation:]+65> <-[UIStatusBar _prepareToSetStyle:animation:forced:]+866> <-[UIStatusBar _requestStyleAttributes:animationParameters:forced:]+391> <-[UIStatusBar requestStyle:animationParameters:forced:]+437> <-[UIStatusBar requestStyle:animated:forced:]+90> <-[UIStatusBar _evaluateServerRegistration]+250> <__45-[UIView(Hierarchy) _postMovedFromSuperview:]_block_invoke+590> <-[UIView(Hierarchy) _postMovedFromSuperview:]+544> <-[UIView(Internal) _addSubview:positioned:relativeTo:]+1967> <-[UIStatusBarWindow setStatusBar:]+288> <-[UIApplication _createStatusBarWithRequestedStyle:orientation:hidden:]+340> <-[UIApplication _runWithMainScene:transitionContext:completion:]+950> <-[UIApplication workspaceDidEndTransaction:]+188> <-[FBSSerialQueue _performNext]+192> <-[FBSSerialQueue _performNextFromRunLoopSource]+45> <__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__+17> <__CFRunLoopDoSources0+556> <__CFRunLoopRun+867> <CFRunLoopRunSpecific+488> <-[UIApplication _run]+402> <UIApplicationMain+171> <main+117> Aug 7 14:27:00 <Error>: CGContextTranslateCTM: invalid context 0x0. Backtrace: <-[UIStatusBarItemView updateContentsAndWidth]+33> <-[UIStatusBarItemView initWithItem:data:actions:style:]+477> <+[UIStatusBarItemView createViewForItem:withData:actions:foregroundStyle:]+134> <-[UIStatusBarLayoutManager _createViewForItem:withData:actions:]+163> <-[UIStatusBarLayoutManager _prepareEnabledItemType:withEnabledItems:withData:actions:itemAppearing:itemDisappearing:]+36 <-[UIStatusBarLayoutManager prepareEnabledItems:withData:actions:]+92> <-[UIStatusBarForegroundView _setStatusBarData:actions:animated:]+797> <-[UIStatusBarForegroundView setStatusBarData:actions:animated:]+332> <__51-[UIStatusBar _prepareToSetStyle:animation:forced:]_block_invoke+360> <+[UIView(Animation) performWithoutAnimation:]+65> <-[UIStatusBar _prepareToSetStyle:animation:forced:]+866> <-[UIStatusBar _requestStyleAttributes:animationParameters:forced:]+391> <-[UIStatusBar requestStyle:animationParameters:forced:]+437> <-[UIStatusBar requestStyle:animated:forced:]+90> <-[UIStatusBar _evaluateServerRegistration]+250> <__45-[UIView(Hierarchy) _postMovedFromSuperview:]_block_invoke+590> <-[UIView(Hierarchy) _postMovedFromSuperview:]+544> <-[UIView(Internal) _addSubview:positioned:relativeTo:]+1967> <-[UIStatusBarWindow setStatusBar:]+288> <-[UIApplication _createStatusBarWithRequestedStyle:orientation:hidden:]+340> <-[UIApplication _runWithMainScene:transitionContext:completion:]+950> <-[UIApplication workspaceDidEndTransaction:]+188> <-[FBSSerialQueue _performNext]+192> <-[FBSSerialQueue _performNextFromRunLoopSource]+45> <__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__+17> <__CFRunLoopDoSources0+556> <__CFRunLoopRun+867> <CFRunLoopRunSpecific+488> <-[UIApplication _run]+402> <UIApplicationMain+171> <main+117> Aug 7 14:27:00 <Error>: CGContextRestoreGState: invalid context 0x0. Backtrace: <-[UIStatusBarItemView updateContentsAndWidth]+33> <-[UIStatusBarItemView initWithItem:data:actions:style:]+477> <+[UIStatusBarItemView createViewForItem:withData:actions:foregroundStyle:]+134> <-[UIStatusBarLayoutManager _createViewForItem:withData:actions:]+163> <-[UIStatusBarLayoutManager _prepareEnabledItemType:withEnabledItems:withData:actions:itemAppearing:itemDisappearing:]+36 <-[UIStatusBarLayoutManager prepareEnabledItems:withData:actions:]+92> <-[UIStatusBarForegroundView _setStatusBarData:actions:animated:]+797> <-[UIStatusBarForegroundView setStatusBarData:actions:animated:]+332> <__51-[UIStatusBar _prepareToSetStyle:animation:forced:]_block_invoke+360> <+[UIView(Animation) performWithoutAnimation:]+65> <-[UIStatusBar _prepareToSetStyle:animation:forced:]+866> <-[UIStatusBar _requestStyleAttributes:animationParameters:forced:]+391> <-[UIStatusBar requestStyle:animationParameters:forced:]+437> <-[UIStatusBar requestStyle:animated:forced:]+90> <-[UIStatusBar _evaluateServerRegistration]+250> <__45-[UIView(Hierarchy) _postMovedFromSuperview:]_block_invoke+590> <-[UIView(Hierarchy) _postMovedFromSuperview:]+544> <-[UIView(Internal) _addSubview:positioned:relativeTo:]+1967> <-[UIStatusBarWindow setStatusBar:]+288> <-[UIApplication _createStatusBarWithRequestedStyle:orientation:hidden:]+340> <-[UIApplication _runWithMainScene:transitionContext:completion:]+950> <-[UIApplication workspaceDidEndTransaction:]+188> <-[FBSSerialQueue _performNext]+192> <-[FBSSerialQueue _performNextFromRunLoopSource]+45> <__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__+17> <__CFRunLoopDoSources0+556> <__CFRunLoopRun+867> <CFRunLoopRunSpecific+488> <-[UIApplication _run]+402> <UIApplicationMain+171> <main+117>
这是9b5中的一个错误:
https://forums.developer.apple.com/thread/13683
用苹果电脑提供雷达。
您可以通过以下菜单设置环境variables:产品 – >scheme – >编辑scheme。 在“运行”项下,find“参数”标签,在标签页中添加“ CG_CONTEXT_SHOW_BACKTRACE
”,将会看到“环境variables”,并将其值设置为YES。
这个问题发生在Xcode 7上。在我的情况下,我从Info.plist
移除了UIViewControllerBasedStatusBarAppearance
并解决了问题! 在这篇文章中看到答案:
在Xcode 7上:
如果你仍然想隐藏状态栏,只需将Info.plist
文件中的UIViewControllerBasedStatusBarAppearance
改为View controller-based status bar appearance
。 不要忘了把它设置为NO