[英]Open Viewcontroller from AppDelegate with Link
我有一個小問題。
我嘗試發送推送通知來控制View Controller。
我來到那里,但是新的“頁面”沒有打開。 如果我發送相同的消息但帶有操作按鈕,則它可以工作。
謝謝克里斯
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];
}
新聞標簽
-(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];
}
您是從應用程序委托中發布代碼的,但是其中的方法是什么?
應用程序委托可以檢索有關通知的信息,並在其- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
方法中對其進行響應。 在這里,您可以執行任何操作,並使用通知來告知您的決定。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.