Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
864 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 Answer

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...