8

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?

1 Answer 1

1

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.

1
  • @G M: I'm seeing exactly the same thing and would agree that it seems to be down to the double click. What's your reference for this answer though? Any documentation/forum posts you can link us to?
    – sam-w
    Nov 7, 2013 at 13:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.