3

I'm attempting to change a view when specific push notifications come through, I've had minor success. (Using parse with push notifications, catering for when the App is open and closed).

My Storyboard looks like this, I'm attempting to change the view within AppDelegate to DetailViewController. enter image description here

Now I'm able to change views by changing the root controller, but I've only been able to attach either my tab view or the navigation not both.

 UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPhone" bundle:nil];
    DetailViewController *detail = (DetailViewController *)[mainStoryboard instantiateViewControllerWithIdentifier:@"detail"];
    [detail setDetailItem:StreamData[2]];

    self.window.rootViewController = detail;

And of course the use of (below) only works in other controllers.

[self.navigationController pushViewController:detail animated:YES];

I'm wondering if this can be achieved from AppDelegate while maintaing the tabbar at the bottom and the navigation at the top?

My initial work around is to set a trigger from the AppDelegate to a global var accessible from all controllers and then use something like viewDidAppear to check if they view needs to change. This seems way too resource intensive though but it maintains my layouts.

My issue is similar to this: pushing view controller inside a tab bar from app delegate, after a notification

4

1 に答える 1

5

私はあなたの問題を回避しました。いくつかのシーンを作成しましたが、あなたのケースでうまくいくかどうかわかりません。とにかくやってみる

私の絵コンテ

ここに画像の説明を入力

私がやった事

 UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];

[(UITabBarController *)self.window.rootViewController setSelectedIndex:1];
UINavigationController *nav = [[(UITabBarController *)self.window.rootViewController viewControllers]objectAtIndex:1];
UIViewController *detail = [mainStoryboard instantiateViewControllerWithIdentifier:@"detail"];
[nav pushViewController:detail animated:NO];

これにより、タブバーとナビゲーションコントローラーを備えた最初のビューとしてボタンを備えた詳細ビューコントローラーが得られます

于 2013-05-24T08:04:32.673 に答える