关于CGContextRef无效的问题

  • 在实现CGContextRef制图的过程用,因为直接调用“[self drawRect:self.bounds]”出现啦如下错误:
Nov  7 15:22:09 7777 PasswordDemo[15969] : CGContextSaveGState: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context  and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update.
Nov  7 15:22:09 7777 PasswordDemo[15969] : CGContextBeginPath: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context  and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update.
Nov  7 15:22:09 7777 PasswordDemo[15969] : CGContextSetLineWidth: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context  and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update.
Nov  7 15:22:09 7777 PasswordDemo[15969] : CGContextSetLineCap: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context  and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update.
Nov  7 15:22:09 7777 PasswordDemo[15969] : CGContextSetLineJoin: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context  and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update.
Nov  7 15:22:09 7777 PasswordDemo[15969] : CGContextSetRGBStrokeColor: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context  and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update.
Nov  7 15:22:09 7777 PasswordDemo[15969] : CGContextMoveToPoint: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context  and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update.

解决办法:
其实在实现的制图过程中,我们不需要直接调用“[self drawRect:self.bounds]”,只要调用“[self setNeedsDisplay]”即可。

你可能感兴趣的:(关于CGContextRef无效的问题)