0
我想顯示視圖中的本地通知的警報的觸摸,我的問題是下面加載意見
鑑於其三種視圖V1,V2,V3,我已經觸發代碼對於該代碼在下面給出,這三個不同的視圖按鈕從不同視圖
notificationObject_ViewOne = [[UILocalNotification alloc]init];
notificationObject_ViewOne.fireDate = [NSDate dateWithTimeIntervalSinceNow:20];
notificationObject_ViewOne.timeZone = [NSTimeZone defaultTimeZone];
notificationObject_ViewOne.alertBody = @"You are notified";
notificationObject_ViewOne.alertAction = @"View 1";
notificationObject_ViewOne.applicationIconBadgeNumber = [[UIApplication sharedApplication]applicationIconBadgeNumber]+1;
NSDictionary *infoDict = [NSDictionary dictionaryWithObjectsAndKeys:@"Object 1", @"Key 1", nil];
notificationObject_ViewOne.userInfo = infoDict;
[[UIApplication sharedApplication]scheduleLocalNotification:notificationObject_ViewOne];
[notificationObject_ViewOne release];
SecondViewController *sec = [[SecondViewController alloc]initWithNibName:@"SecondViewController" bundle:nil];
[self.navigationController pushViewController:sec animated:YES];
[sec release];
的代碼而改變在所述第二視圖來觸發通知是
notificationObject_ViewTwo = [[UILocalNotification alloc]init];
notificationObject_ViewTwo.fireDate = [NSDate dateWithTimeIntervalSinceNow:35];
notificationObject_ViewTwo.timeZone = [NSTimeZone defaultTimeZone];
notificationObject_ViewTwo.alertBody = @"You are notified";
notificationObject_ViewTwo.alertAction = @"View 2";
notificationObject_ViewTwo.applicationIconBadgeNumber = [[UIApplication sharedApplication]applicationIconBadgeNumber]+1;
NSDictionary *infoDict = [NSDictionary dictionaryWithObjectsAndKeys:@"Object 2", @"Key 2", nil];
notificationObject_ViewTwo.userInfo = infoDict;
[[UIApplication sharedApplication]scheduleLocalNotification:notificationObject_ViewTwo];
[notificationObject_ViewTwo release];
ThirdViewController *ThirdObj = [[ThirdViewController alloc]initWithNibName:@"ThirdViewController" bundle:nil];
[self.navigationController pushViewController:ThirdObj animated:YES];
[ThirdObj release];
現在,應用程序的委託裏面我正在處理與下面
UILocalNotification *localNotificationObject = [launchOptions objectForKey:UIApplicationLaunchOptionsLocalNotificationKey];
if (localNotificationObject)
{
firstObject = [[FirstViewController alloc]initWithNibName:@"FirstViewController" bundle:nil];
NSLog(@"noti %@",[localNotificationObject.userInfo valueForKey:@"Key 1"]);
// firstObject.title = @"FirstView";
[self.window addSubview:firstObject.view];
}
else if(localNotificationObject)
{
SecondViewController *secondObject = [[SecondViewController alloc]initWithNibName:@"SecondViewController" bundle:nil];
NSLog(@"noti %@",[localNotificationObject.userInfo valueForKey:@"Key 2"]);
[self.window addSubview:secondObject.view];
//secondObject.title = @"Second View";
}
else if(localNotificationObject)
{
ThirdViewController *thirdObject = [[ThirdViewController alloc]initWithNibName:@"ThirdViewController" bundle:nil];
NSLog(@"noti %@",[localNotificationObject.userInfo valueForKey:@"Key 3"]);
[self.window addSubview:thirdObject.view];
// thirdObject.title = @"Third View";
}
else
{
firstObject = [[FirstViewController alloc]initWithNibName:@"FirstViewController" bundle:nil];
UINavigationController *navC = [[UINavigationController alloc]initWithRootViewController:firstObject];
[self.window addSubview:navC.view];
}
給予代碼的通知上面的代碼寫在申請做應用程序的委託文件
所以我想在這裏做的光潔度啓動方法是當通知1的警報框到來時v1應該加載,當通知2的警報到來時v2應該加載。
但事情是v1獲得完美加載,但是當涉及到v2和v3時,userInfo對於它們是null,v1默認加載。我在UIApplication委託方法中做了同樣的處理本地通知,但結果仍然相同。
請爲我提供一些相同的指導或鏈接。
在此先感謝