我有一个小问题。
我尝试使用推送通知来控制View Controller。
然而,我来到那里,新的"页面"没开。 如果我发送相同但有一个动作按钮它可以工作。
谢谢你,Chris
AppDelegate.m
RootViewController *rootViewController = (RootViewController*)self.window.rootViewController;
[rootViewController openLinkNews];
RootViewController.m
- (void)awakeFromNib {
self.contentViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"contentController"];
self.menuViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"menuController"];
}
-(void)openLinkNews {
NewsTab *theLink = [[NewsTab alloc] init];
[theLink openNewsPerLink];
}
NewsTab.m
-(void)openNewsPerLink{
NSLog(@"You are here!");
dbConnect = [[DbConnect alloc] init];
getNewsLast = [dbConnect getNewsLast];
DbConnect *news = [getNewsLast objectAtIndex:0];
NewsTab * infoController = [self.storyboard instantiateViewControllerWithIdentifier:@"NewsOpenViewController"];
NewsOpen *detailViewController = (NewsOpen *) infoController;
detailViewController.NewsHeadline = news.NewsHeadline;
detailViewController.NewsInformation = news.NewsInformation;
detailViewController.NewsFrom = news.NewsFrom;
detailViewController.NewsDate = news.NewsDate;
[self.navigationController pushViewController:infoController animated:YES];
}
-(IBAction)ButtonTest:(id)sender {
[self openNewsPerLink];
}
答案 0 :(得分:0)
您是从您的应用代表发布的代码,但是该方法是什么?
应用代理可以检索有关通知的信息,并使用其- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
方法对其进行响应。从那里你可以做任何你想做的事情,并使用通知来告知你的决定。