我爲示例項目使用了故事板。該架構是Login View Controller和Home PageView控制器。用戶單擊Home PageView控制器中的按鈕以啓動本地通知。Xcode 6.1:快照未呈現的視圖
-(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];
}
此代碼放在AppDelegate的文件:
- (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");
}
現在推應用到後臺狀態下我收到以下消息在控制檯,但如預期本地通知工作正常後。
快照未呈現的視圖會導致空的快照。確保您的視圖在屏幕更新後的快照或快照之前已呈現至少一次。
此消息與什麼有關?
我認爲*它必須與進入背景時形成的屏幕截圖相關。不幸的是,我不知道這是一個嚴重的問題還是隻是一些我可以選擇忽略的信息。我很想知道你是否有任何進展或有任何信息需要我去解決。 – button 2015-03-09 19:29:35
你解決了這個問題嗎? – 2015-07-15 19:28:04