使用iOS 6.0的多字节键盘编辑uitextfield时,"无效上下文错误0x0"

ter*_*rut 8 objective-c ios6

我使用Xcode 4.5.1更新了iOS 6.0 SDK,在我的应用程序中使用多字节键盘(例如日语键盘)编辑UITextField时,我的上下文错误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
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
Run Code Online (Sandbox Code Playgroud)

我试图创建新项目,但我遇到了这些错误.以下是新项目代码:

- (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;
}
Run Code Online (Sandbox Code Playgroud)

如果使用美国键盘进行编辑,则不会出现错误.你知道如何避免这个问题吗?

小智 1

此错误可以追溯到双击空的 uitextfield。这是 iOS 中的一个错误。将文本字段初始化为“”,错误就会消失。