当通知弹出时,应用程序崩溃,我点击查看" ...似乎正在发送某些消息,并且它不知道发生了什么.我,也不知道发生了什么,因为目标C对我来说是一门外语.有人有什么想法吗?--------- Console Log ---------- 11/7/29 11:05:48 AM下午确认[12004]-[UIConcreteLocalNotification absoluteString]:无法识别的选择器已发送到实例0x5c22240 7/29/11 11:05:48 AM Afternoon Affirmations[12004] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIConcreteLocalNotification absoluteString]: unrecognized selector sent to instance 0x5c22240'*** Call stack at first throw:( 0 CoreFoundation 0x017f65a9 __exceptionPreprocess + 185 1 libobjc.A.dylib 0x0194a313 objc_exception_throw + 44 2 CoreFoundation 0x017f80bb -[NSObject(NSObject) doesNotRecognizeSelector:] + 187 3 CoreFoundation 0x01767966 ___forwarding___ + 966 4 CoreFoundation 0x01767522 _CF_forwarding_prep_0 + 50 5 Afternoon Affirmations 0x00002f21 -[AppDelegate application:didFinishLaunchingWithOptions:] + 257 6 UIKit 0x002f7c89 -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 1163 7 UIKit 0x002f9d88 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 439 8 UIKit 0x00304617 -[UIApplication handleEvent:withNewEvent:] + 1533 9 UIKit 0x002fcabf -[UIApplication sendEvent:] + 71 10 UIKit 0x00301f2e _UIApplicationHandleEvent + 7576 11 GraphicsServices 0x020e5992 PurpleEventCallback + 1550 12 CoreFoundation 0x017d7944 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52 13 CoreFoundation 0x01737cf7 __CFRunLoopDoSource1 + 215 14 CoreFoundation 0x01734f83 __CFRunLoopRun + 979 15 CoreFoundation 0x01734840 CFRunLoopRunSpecific + 208 16 CoreFoundation 0x01734761 CFRunLoopRunInMode + 97 17 UIKit 0x002f97d2 -[UIApplication _run] + 623 18 UIKit 0x00305c93 UIApplicationMain + 1160 19 Afternoon Affirmations 0x00002d7f main + 127 20 Afternoon Affirmations 0x00002cf5 start + 53)7/29/11 11:05:48 AM UIKitApplication:com.InTheRooms.AfternoonAffirmations[0x9a52][12004] terminate called after throwing an instance of 'NSException'解决方案好,我发现了问题,它存在于AppDelegate.m文件中,更确切地说是在方法didFinishLaunchingWithOptions中.该方法假定第一个选项参数为url(但不是通过本地通知启动应用程序时的URL.快捷而肮脏的解决方法是注释代码:- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{ //commented out because it makes the app crash at startup with local notification... /*NSArray *keyArray = [launchOptions allKeys]; if ([launchOptions objectForKey:[keyArray objectAtIndex:0]]!=nil) { NSURL *url = [launchOptions objectForKey:[keyArray objectAtIndex:0]]; self.invokeString = [url absoluteString]; NSLog(@"Mosa_fr_en-busi launchOptions = %@",url); }*/ return [super application:application didFinishLaunchingWithOptions:launchOptions];}I'm having trouble here: I have the app set to not run in the background, and I'm setting a dailyInterval localnotification using a localNotification plugin I found on github here: https://github.com/phonegap/phonegap-plugins/tree/master/iPhone/LocalNotificationThe app crashes when the notification pops up, and I tap "View"... looks like something is being sent along and it doesn't know what's going on. I, also don't know what's going on since Objective C is a foreign language to me. Anyone have any ideas?--------- Console Log ----------7/29/11 11:05:48 AM Afternoon Affirmations[12004] -[UIConcreteLocalNotification absoluteString]: unrecognized selector sent to instance 0x5c222407/29/11 11:05:48 AM Afternoon Affirmations[12004] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIConcreteLocalNotification absoluteString]: unrecognized selector sent to instance 0x5c22240'*** Call stack at first throw:( 0 CoreFoundation 0x017f65a9 __exceptionPreprocess + 185 1 libobjc.A.dylib 0x0194a313 objc_exception_throw + 44 2 CoreFoundation 0x017f80bb -[NSObject(NSObject) doesNotRecognizeSelector:] + 187 3 CoreFoundation 0x01767966 ___forwarding___ + 966 4 CoreFoundation 0x01767522 _CF_forwarding_prep_0 + 50 5 Afternoon Affirmations 0x00002f21 -[AppDelegate application:didFinishLaunchingWithOptions:] + 257 6 UIKit 0x002f7c89 -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 1163 7 UIKit 0x002f9d88 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 439 8 UIKit 0x00304617 -[UIApplication handleEvent:withNewEvent:] + 1533 9 UIKit 0x002fcabf -[UIApplication sendEvent:] + 71 10 UIKit 0x00301f2e _UIApplicationHandleEvent + 7576 11 GraphicsServices 0x020e5992 PurpleEventCallback + 1550 12 CoreFoundation 0x017d7944 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52 13 CoreFoundation 0x01737cf7 __CFRunLoopDoSource1 + 215 14 CoreFoundation 0x01734f83 __CFRunLoopRun + 979 15 CoreFoundation 0x01734840 CFRunLoopRunSpecific + 208 16 CoreFoundation 0x01734761 CFRunLoopRunInMode + 97 17 UIKit 0x002f97d2 -[UIApplication _run] + 623 18 UIKit 0x00305c93 UIApplicationMain + 1160 19 Afternoon Affirmations 0x00002d7f main + 127 20 Afternoon Affirmations 0x00002cf5 start + 53)7/29/11 11:05:48 AM UIKitApplication:com.InTheRooms.AfternoonAffirmations[0x9a52][12004] terminate called after throwing an instance of 'NSException' 解决方案 OK, I found the problem, it's in the file AppDelegate.m and more precisely in the method : didFinishLaunchingWithOptions. The method assumes that the first option parameters is an url (but it's not when we launch the app via a Local Notification. The quick and dirty fix is to comment the code :- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{ //commented out because it makes the app crash at startup with local notification... /*NSArray *keyArray = [launchOptions allKeys]; if ([launchOptions objectForKey:[keyArray objectAtIndex:0]]!=nil) { NSURL *url = [launchOptions objectForKey:[keyArray objectAtIndex:0]]; self.invokeString = [url absoluteString]; NSLog(@"Mosa_fr_en-busi launchOptions = %@",url); }*/ return [super application:application didFinishLaunchingWithOptions:launchOptions];} 这篇关于在点击& quot; View& quot;时,PhoneGap/iOS LocalNotification App崩溃.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
09-14 11:21