我正在开发我的第一个 iPhone 应用程序,到目前为止它运行良好,但突然它开始崩溃并且我不断收到此错误:
2012-08-13 08:39:50.000 OGLGame[36085:10a03]-[ NSCFString setFrame:]:无法识别的选择器发送到实例 0x7368300 2012-08-13 08:39:50.031 OGLGame[36085:10a03](0 CoreFoundation
__except 0x0166203ePreprocesse + 206 1 libobjc.A.dylib
0x01c7fcd6 objc_exception_throw + 44 2 CoreFoundation
0x01663cbd -[NSObject doesNotRecognizeSelector:] + 253 3
CoreFoundation 0x015c8ed0 __ forwarding + 432 4 CoreFoundation 0x015c8cb2 _CF_forwarding_prep_0 + 50 5 OGLGame 0x00004673 -[EAGLView setupScore] + 355 6 OGLGame
0x0000335b - [EAGLView initGame] + 299 7 OGLGame
0x00003217 -[EAGLView initWithCoder:] + 1047 8 UIKit
0x00a48135 -[UIClassSwapper initWithCoder:] + 243 9 UIKit
0x00b47c6e UINibDecoderDecodeObjectForValue + 2276 10 UIKit
0x00b47383 -[UINibDecoder decodeObjectForKey:] + 117 11 UIKit
0x00a47cad -[UIRuntimeConnection initWithCoder:] + 187 12 UIKit
0x00b47c6e UINibDecoderDecodeObjectForValue + 2276 13 UIKit
0x00b4767b UINibDecoderDecodeObjectForValue + 753 14 UIKit
0x00b47383 -[UINibDecoder decodeObjectForKey:] + 117 15 UIKit
0x00a47105 -[UINib instantiateWithOwner:options:] + 817 16 UIKit
0x00a48eb7 -[NSBundle(UINSBundleAdditions) loadNibNamed:owner:options:] + 157 17 用户界面套件
0x00825ce1 -[UIApplication _loadMainNibFileNamed:bundle:] + 58 18 UIKit 0x00825ff8 -[UIApplication _loadMainInterfaceFile] + 225 19 UIKit 0x0082517f -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 279 20 UIKit 处理事件:withNewEvent:withNewEvent 0x008 ] + 1027 21 UIKit 0x00834c38 -[UIApplication sendEvent:] + 68 22 UIKit
0x00828634 _UIApplicationHandleEvent + 8196 23 GraphicsServices
0x03af7ef5 PurpleEventCallback + 1274 24 CoreFoundation
0x01636195 CFRUNLOOP_IS_CALLING_SOUT_FUNCTION_A + 53 25 CoreFoundation 0x0159aff2 __CFRunLoopDoSource1 + 146 26 CoreFoundation 0x015998da __CFRunLoopRun + 2218 27 CoreFoundation
0x01598d84 CFRunLoopRunSpecific + 212 28 CoreFoundation
0x01598c9b CFRunLoopRunInMode + 123 29 UIKit
0x00824c65 -[UIApplication _run] + 576 30 UIKit
0x00826626 UIApplicationMain + 1163 31 OGLGame
0x000029c4 main + 116 32 OGLGame
0x00002945 开始 + 53 33 ???
0x00000001 0x0 + 1)
这是我认为引发错误的函数:
-(无效)setupScore{
scoreLabel = [NSString stringWithFormat:@"foo"]; scoreLabel.frame = CGRectMake(262, 250, 100, 40); [scoreLabel setText: scoreString]; //normally you'll want a transparent background for your label scoreLabel.backgroundColor = [UIColor clearColor]; //you can use non-standard fonts [scoreLabel setFont:[UIFont fontWithName:@"TimesNewRoman" size: 1.0f]]; //change the label's text color scoreLabel.textColor = [UIColor whiteColor]; //you can even create a drop shadow on your label text /*myLabel.layer.shadowOpacity = 0.6; myLabel.layer.shadowRadius = 0.0; myLabel.layer.shadowColor = [UIColor blackColor].CGColor; myLabel.layer.shadowOffset = CGSizeMake(1.0, 1.0);*/ //add it to your view scoreLabel.transform = CGAffineTransformMakeRotation(89.53); [self addSubview:scoreLabel]; }
-(无效)resetScore { score = 0; scoreLabel.textColor = [UIColor blackColor]; [分数标签发布];}
-(void)drawScore{
[scoreLabel setText: scoreString]; }
有谁知道如何解决这个奇怪的崩溃?
如果您需要更多代码,请告诉我,谢谢!