0
所以,當你點擊接收推送通知視圖時,應用程序打開它呈現視圖推新的控制器與有關通知的細節我想要做的是。我正在使用UITabBarController和UINavigationControllers。任何幫助將不勝感激,我試過尋找,但我似乎無法找到任何指向正確方向的東西。低於當前代碼:如何在應用程序關閉時打開推送通知時推送新視圖?
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeSound)];
[application setStatusBarStyle:UIStatusBarStyleBlackOpaque];
tabBarController = [[UITabBarController alloc] init];
controller = [[controller alloc] init];
UINavigationController *controller1 = [[[UINavigationController alloc] initWithRootViewController:controller] autorelease];
controller1.tabBarItem.image = [UIImage imageNamed:@"icon_news.png"];
[controller setTitle:@"View"];
[controller release];
controller = [[controller alloc] init];
UINavigationController *controller2 = [[[UINavigationController alloc] initWithRootViewController:controller] autorelease];
controller2.tabBarItem.image = [UIImage imageNamed:@"icon_news.png"];
[controller setTitle:@"View"];
[controller release];
controller = [[controller alloc] init];
UINavigationController *controller3 = [[[UINavigationController alloc] initWithRootViewController:controller3] autorelease];
controller3.tabBarItem.image = [UIImage imageNamed:@"icon_news.png"];
[controller setTitle:@"View"];
[controller release];
controller = [[controller alloc] init];
UINavigationController *controller4 = [[[UINavigationController alloc] initWithRootViewController:controller] autorelease];
controller4.tabBarItem.image = [UIImage imageNamed:@"icon_news.png"];
[controller setTitle:@"View"];
[controller release];
controller = [[controller alloc] init];
UINavigationController *controller5 = [[[UINavigationController alloc] initWithRootViewController:controller] autorelease];
controller5.tabBarItem.image = [UIImage imageNamed:@"icon_news.png"];
[controller setTitle:@"View"];
[controller release];
tabBarController.viewControllers = [NSArray arrayWithObjects:controller1, controller2, controller3, controller4, controller5, nil];
[window addSubview:tabBarController.view];
[window makeKeyAndVisible];
launchDefault = YES;
//[self performSelector:@selector(handlePostLaunch) withObject:nil afterDelay:0];
// Push Notification info
NSDictionary *apns = [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];
NSString *result = [[[apns valueForKey:@"aps"] valueForKey:@"alert"] valueForKey:@"loc-args"];
NSString *playerID = [NSString stringWithFormat:@"%@", result];
playerID = [[playerID componentsSeparatedByCharactersInSet:[NSCharacterSet newlineCharacterSet]] componentsJoinedByString:@""];
playerID = [playerID stringByReplacingOccurrencesOfString:@" " withString:@""];
playerID = [playerID stringByReplacingOccurrencesOfString:@"(" withString:@""];
playerID = [playerID stringByReplacingOccurrencesOfString:@")" withString:@""];
NSLog(@"Player ID: %@", playerID);
if (![playerID isEqualToString:@"null"]) {
if (!detailViewController) {
detailViewController = [[PlayerDetailViewController alloc] init];
}
NSManagedObjectContext *moc = [[AppController sharedAppController] managedObjectContext];
NSFetchRequest *req = [[NSFetchRequest alloc] init];
NSEntityDescription *entity = [NSEntityDescription entityForName:@"Players"
inManagedObjectContext:moc];
[req setEntity:entity];
NSPredicate *pre = [NSPredicate predicateWithFormat:@"playerID=%@", playerID];
[req setPredicate:pre];
NSError *error;
NSArray *list = [moc executeFetchRequest:req error:&error];
[req release];
Players *player = [list lastObject];
[detailViewController setPlayer:player];
//Want to Push view here
[detailViewController release];
detailViewController = nil;
}
return YES;
}
我正確地獲得通知信息,我有什麼用自動推送通知的應用程序中的詳細信息視圖的問題。對不起,如果我的問題措辭不佳。 – nlutterman 2011-05-06 21:27:55
編輯我的答案,我的錯誤,並沒有完全解決問題。 – 2011-05-06 21:40:37
我都試過[[[tabBarController selectedViewController] navigationController] pushViewController:detailViewController動畫:YES];和[[tabBarController selectedViewController] presentModalViewController:detailViewController animated:YES];但是它們都在int main()函數中結束了一個SIGKILL。我是否應該如何將視圖推向堆棧?我認爲pushViewcontroller是我正在尋找。 – nlutterman 2011-05-06 22:12:12