I updated iOS 6.0 SDK with Xcode 4.5.1, and I had invalid context error 0x0 when editing UITextField with mult byte keyboard(e.g. japanese keyboard) in my application. The following is error:
Oct 9 21:46:44 example.com Example[2303] <Error>: CGContextSaveGState: invalid context 0x0
Oct 9 21:46:44 example.com Example[2303] <Error>: CGContextDrawLinearGradient: invalid context 0x0
Oct 9 21:46:44 example.com Example[2303] <Error>: CGContextSetFillColorWithColor: invalid context 0x0
Oct 9 21:46:44 example.com Example[2303] <Error>: CGContextFillRects: invalid context 0x0
Oct 9 21:46:44 example.com Example[2303] <Error>: CGContextFillRects: invalid context 0x0
Oct 9 21:46:44 example.com Example[2303] <Error>: CGContextSetFillColorWithColor: invalid context 0x0
Oct 9 21:46:44 example.com Example[2303] <Error>: CGContextFillRects: invalid context 0x0
Oct 9 21:46:44 example.com Example[2303] <Error>: CGContextSaveGState: invalid context 0x0
Oct 9 21:46:44 example.com Example[2303] <Error>: CGContextDrawLinearGradient: invalid context 0x0
Oct 9 21:46:44 example.com Example[2303] <Error>: CGContextSetFillColorWithColor: invalid context 0x0
Oct 9 21:46:44 example.com Example[2303] <Error>: CGContextFillRects: invalid context 0x0
Oct 9 21:46:44 example.com Example[2303] <Error>: CGContextFillRects: invalid context 0x0
Oct 9 21:46:44 example.com Example[2303] <Error>: CGContextSetFillColorWithColor: invalid context 0x0
Oct 9 21:46:44 example.com Example[2303] <Error>: CGContextFillRects: invalid context 0x0
I tried to create new project and I had these errors. The following is new project code:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
UITextField *foo = [[UITextField alloc] initWithFrame:CGRectMake(30, 30, 200, 50)];
[self.window addSubview:foo];
return YES;
}
if you edit with US keyboard, you will not have errors. Do you know how to avoid this problem?
This error can be traced to double clicking on a uitextfield that is empty. It is a bug in iOS. Init your textfield to " " and the error will disappear.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With