当前位置: 首页 > 知识库问答 >
问题:

如何设置CG_上下文_显示_回溯环境变量?

席宜修
2023-03-14

我的视图中有三个按钮。在viewDidLoad()中设置角Radus后:button.layer.cornerRadius=20我在日志中收到以下错误消息:

 <Error>: CGContextSaveGState: invalid context 0x0. 
If you want to see the backtrace, please set 
CG_CONTEXT_SHOW_BACKTRACE environmental variable.

问题:

好吧,我现在从消息中找到了回溯。这对我没有任何意义。请帮帮忙...

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>

共有3个答案

滕璞瑜
2023-03-14

这个问题发生在Xcode 7上。在我的例子中,我从Info中删除了UIViewControllerBasedStatusBarAppearance。plist问题解决了!请参阅本文中的答案:

吴丁雷
2023-03-14

是9b5中的bug:
https://forums.developer.apple.com/thread/13683

向Apple提交RADAR。

孟树
2023-03-14

您可以通过以下菜单设置环境变量:Product-

 类似资料:
  • 问题内容: 我知道这个问题以前已经问过很多,但是我确实读过,我会告诉你我所得到的。 我将列出在 OS X Yosemite 10.10.1* 中执行的命令 * Java版本 java -fullversion 哪个java 未设置Java home变量,因为当我这样做时: echo $ java_home 或 echo $ JAVA_HOME 或 echo $ Java_Home 我在终端上什么也

  • 问题内容: 我开始研究一个项目,它使用了Github私有存储库中的一些私有模块,每当我尝试运行它时,都会出现以下错误: 验证github.com/repoURL/go- proto@v2.86.0+incompatible/go.mod:github.com/repoURL/go- proto@v2.86.0+incompatible/go.mod:阅读https://sum.golang。 or

  • 问题内容: 我的视图中有三个按钮。在viewDidLoad()中设置cornerRadus之后:我在日志中收到以下错误消息: 问题: 如何设置CG_CONTEXT_SHOW_BACKTRACE环境变量? 或者如何解决此警告? 好吧,现在我已经从消息中得到了回溯。这对我来说没有任何意义。请帮忙… 问题答案: 这是9b5中的错误:https://forums.developer.apple.com/t

  • 假设我有. env文件包含如下行: 不像普通的文件有< code>export前缀,所以我不能直接获取文件。 创建从. env文件加载内容并将其设置为环境变量的外壳脚本的最简单方法是什么?

  • 本文向大家介绍如何在Linux上设置python环境变量PYTHONPATH?,包括了如何在Linux上设置python环境变量PYTHONPATH?的使用技巧和注意事项,需要的朋友参考一下 要将Linux上的PYTHONPATH设置为指向Python以在其他目录中查找模块和包导入,请按如下所示导出PYTHONPATH变量: 在这种情况下,我们将foo目录添加到PYTHONPATH中。请注意,我们

  • 本文向大家介绍如何在Mac上设置python环境变量PYTHONPATH?,包括了如何在Mac上设置python环境变量PYTHONPATH?的使用技巧和注意事项,需要的朋友参考一下 要在Mac OS上将PYTHONPATH设置为指向Python以在其他目录中查找模块和包导入,请按如下所示导出PYTHONPATH变量: 在这种情况下,将foo目录添加到PYTHONPATH。请注意,我们将附加它,而