现在我的代码是一个应用程序委托、一个视图控制器和一个主视图现在我只是想插入一个大图像作为背景,但我不知道把它放在哪里,我得到了一个运行模拟时出错
<Error>: CGContextRestoreGState: 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.
- (void) applicationDidBecomeActive: (UIApplication *) application {
NSLog(@"AAAAAAAAAA");
[self startGameLoop];
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
NSLog(@"AAAAA");
mainView = [[MainView alloc] initWithFrame: [UIScreen mainScreen].applicationFrame];
mainView.backgroundColor = [UIColor grayColor];
[self.window addSubview: mainView];
[self.window makeKeyAndVisible];
[self startGameLoop];
return YES;
}
- (void) startGameLoop {
quack = [NSTimer scheduledTimerWithTimeInterval:.0303 target:self selector:@selector(loop) userInfo:nil repeats:YES];
NSLog(@"Game Loop timer instance: %@", quack);
mainView.backgroundColor = [UIColor grayColor];
}
- (void) loop {
NSLog(@"BBBBBB");
pic = [UIImage imageNamed:@"f1.png"];
[pic drawAtPoint:CGPointMake(160, 0)];
[mainView setNeedsDisplay];
}
- (void) drawRect: (CGRect) rect {
maps = [UIImage imageNamed:@"map.png"];
[maps drawAtPoint:CGPointMake(W/2, 0)];
}