我正在为我的示例项目使用storyboard.该体系结构是Login View Controller和Home PageView控制器.用户单击Home PageView控制器中的按钮以启动本地通知.
-(IBAction)startLocalNotification { // Bind this method to UIButton action NSLog(@"startLocalNotification"); UILocalNotification *notification = [[UILocalNotification alloc] init]; notification.fireDate = [NSDate dateWithTimeIntervalSinceNow:7]; notification.alertBody = @"This is local notification!"; notification.timeZone = [NSTimeZone defaultTimeZone]; notification.soundName = UILocalNotificationDefaultSoundName; notification.applicationIconBadgeNumber = 10; [[UIApplication sharedApplication] scheduleLocalNotification:notification]; }
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Override point for customization after application launch. if ([UIApplication instancesRespondToSelector:@selector(registerUserNotificationSettings:)]){ [application registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeAlert|UIUserNotificationTypeBadge|UIUserNotificationTypeSound categories:nil]]; } [launchOptions valueForKey:UIApplicationLaunchOptionsLocalNotificationKey]; // Override point for customization after application launch. return YES; } - (void)applicationDidBecomeActive:(UIApplication *)application { [UIApplication sharedApplication].applicationIconBadgeNumber = 0; NSLog(@"didReceiveLocalNotification"); }
现在将应用程序推送到后台状态后,我在控制台中收到消息,但本地通知正常工作正常.
快照未呈现的视图会导致空快照.确保在屏幕更新后快照或快照之前,您的视图至少呈现过一次.
这条消息与什么有关?
解决方法
我有我认为可以作为’答案’站起来……而且这几乎肯定没什么不对,但可能是iOS(8.1.3 / 8.2)的问题.据我所知,这是无害的.
我玩弄了这个,发现它与UITextField / Keyboard有关.
所以只有一个文本字段的单个视图应用程序,请按照以下步骤操作(仅在iPad上试用):
>构建并运行
>将焦点放在文本字段中
>关闭键盘(它应该已打开)
>单击主页按钮(应用程序进入后台)
>返回应用程序
>单击主页按钮(应用程序进入后台)
>观察日志输出.
这是一个示例项目:https://github.com/duttski/TestForStrangeSnapshotMessage.
归档为bug,并试图通过开发论坛获取一些信息.
更新:我认为这可能会在以后的版本中修复.但我没有测试过它.在开发论坛上发言后,我被告知这不用担心.