Reputation: 7605
- (void)application:(UIApplication *)application performActionForShortcutItem:(UIApplicationShortcutItem *)shortcutItem completionHandler:(void (^)(BOOL))completionHandler {
MainView *Main=[[MainView alloc]initWithNibName:@"MainView" bundle:nil];
// This module to collect metrics for Notification received, Notification displayed
UINavigationController *NavBar=[[UINavigationController alloc] initWithRootViewController:Main];
// react to shortcut item selections
NSLog(@"A shortcut item was pressed. It was %@.", shortcutItem.localizedTitle);
if([(NSString *)shortcutItem.localizedTitle isEqualToString:@"Store"])
{
PurchaseView *purchaseViewController = [[PurchaseView alloc] initWithNibName:@"PurchaseView" bundle:nil];
[NavBar pushViewController:purchaseViewController animated:YES];
}
}
I enter the if([(NSString *)shortcutItem.localizedTitle isEqualToString:@"Store"]) loop and I see the code executing. But the PurchaseView.xib never loads. I have similar code for Push Notification and it works when I am pushing a view to load.
Any help would be appreciated.
Upvotes: 0
Views: 56
Reputation: 38142
The problem here is bad view hierarchy. You added your XIB
file's view controller to a brand new UINavigationController
which does not exists anywhere in the view hierarchy. I believe you want to do something like this:
UINavigationController *navBar = (UINavigationController *) self.tabBarController.selectedViewController;
[navBar pushViewController:purchaseViewController animated:YES];
Again, above is a hypothetical example. You need to find out the right UINavigationController
in your view hierarchy.
Upvotes: 2