Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
874 views
in Technique[技术] by (71.8m points)

xcode - CGContextSaveGState: invalid context 0x0 Error only on device

Update: I am using XCode 7 Beta with Swift 2.0

When I try to run my app on an iPhone I get these 3 errors:

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

When I enable to CG_CONTEXT_SHOW_BACKTRACE variable I get this:

Backtrace:
      <<redacted>+40>
       <<redacted>+432>
        <<redacted>+144>
         <<redacted>+172>
          <<redacted>+332>
           <<redacted>+112>
            <<redacted>+820>
             <<redacted>+688>
              <<redacted>+356>
               <<redacted>+80>
                <<redacted>+808>
                 <<redacted>+344>
                  <<redacted>+420>
                   <<redacted>+104>
                    <<redacted>+284>
                     <<redacted>+556>
                      <<redacted>+504>
                       <<redacted>+1792>
                        <<redacted>+220>
                         <<redacted>+284>
                          <<redacted>+920>
                           <<redacted>+168>
                            <<redacted>+184>
                             <<redacted>+56>
                              <<redacted>+24>
                               <<redacted>+540>
                                <<redacted>+724>
                                 <CFRunLoopRunSpecific+384>
                                  <<redacted>+460>
                                   <UIApplicationMain+204>
                                    <main+164>

I'm not sure how to interpret this, I am not using any CoreGraphics content in my code, and the other similar questions had answers that did not work for me. I understand it can be difficult to help debug without code, but I can't figure out what code is related to this, so if anyone has an idea I can post more code.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

From my experimentation, this seems to be due to defining UIViewControllerBasedStatusBarAppearance in Info.plist.

It happens on iOS 9 (beta & GM) but not on 8.4.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...