2014-10-12 66 views
0

我有一個介紹,像這樣一個模式視圖控制器:獲取一個UIViewController推到另一個控制器

[self presentViewController:photo animated:YES completion:nil]; 

這樣的照片是一個模式視圖控制器,但是當它完成我要推到導航視圖像這樣的控制器:

[self dismissViewControllerAnimated:NO completion:^{ 

    // UINavigationController *nav = [[UINavigationController alloc] init]; 
    //nav.delegate = self; 

    ProfilesViewController *profile = [[ProfilesViewController alloc] init]; 
    [_nav pushViewController:profile animated:YES]; 
}]; 

nav是照片的視圖控制器,也有委派的屬性。仍然不工作,所以我錯過了什麼?

+0

等待!不要忘記** transitionFromViewController:toViewController:duration:options:animations:completion:**這可能是你在做什麼之後。 – Fattie 2014-10-12 12:02:39

回答

0

不要複雜的東西,而它可以很容易實現,

在視圖控制器在那裏你呈現照片模式視圖控制器,進行通知這樣目前它,

[self presentViewController:photo animated:YES completion:^{ 
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(pushToNextView:) name:@"someNotification" object:nil]; 
}]; 

並與調用該通知這樣解散你的照片模態視圖控制器

[self dismissViewControllerAnimated:YES completion:^{ 
    [[NSNotificationCenter defaultCenter] postNotificationName:@"someNotification" object:nil]; 
}]; 

現在你可以推到另一個視圖控制器這樣,

- (void) pushToNextView:(NSNotification *)notification { 
    //If you want some value from your notification 
    //NSDictionary *someValue = notification.object; 
    [self.navigationController pushViewController:ProfilesViewController animated:YES]; 
} 
+0

沒關係,所以而不是對象:無我可以做的對象:@「價值」,然後抓取notification.object該值? – cdub 2014-10-12 08:49:32

+0

是的,你可以。即使你也可以在'NSDictionary'中傳遞多個值。 – Hemang 2014-10-12 08:50:31

+0

一個問題是在推送之前它仍然回到主視圖控制器。我看到應用程序沒有這個。 – cdub 2014-10-12 09:05:56

相關問題