2012-05-09 5 views
4

私は基本的にsplitViewControllerのように動作するcontainerView Controllerを持っています。ContainerViewController内のUINavigationController popViewのファンキー

私はcontainerViewControllerの内部にUINavigationControllerを追加しようとしていますが、うまくいきます。

私は、ストーリーボードにUIViewControllersの束を接続してUINavigationControllerを作成しました。これらのUIViewはすべて「プッシュ」セグによって連結されています。このNavigationControllerをストーリーボードから取り出し、コードを使用してContainerViewControllerに貼り付けます。次に、NavigationControllerをどこに表示するか、ボタンをクリックするか、プッシュアニメーションはContainerViewControllerのNavigationControllerフレーム内でのみ発生します。

しかし、NavigationControllerのコードからpopViewControllerを呼び出すと、ContainerViewController全体がアニメーション表示されます。私は望んでいない、私はNavigationControllerのみをアニメーション化したい。

誰もがそれをなぜ知っていますか?

ContainerViewControllerの内部にUINavigationControllerがあり、NavigationControllerでpopViewControllerを使用できる場合、アニメーションはUINavigationControllerのみになり、内部にあるContainerViewControllerではなくアニメーションになるようにしますか?

+2

これまでの解決方法はありましたか? – endy

答えて

1

私もこの問題を抱えていました。それは私のプッシュにも影響を与えていました。私の回避策は、ストーリーボードの代わりにコードを使用することでした。

- (void) switchToView:(NSString *)identifier { 
    UIViewController *target = [self getOrCreateViewController:identifier]; 
    [self switchToViewController:target identifier:identifier]; 
} 

// If you need to interact with the VC before it is pushed break it into 2 step process 
- (UIViewController *) getOrCreateViewController:(NSString *)identifier { 
    NSArray *children = [self.viewControllers filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"restorationIdentifier == %@", identifier, nil]]; 
    UIViewController *target = (children.count > 0 ? children[0] : [self.storyboard instantiateViewControllerWithIdentifier:identifier]); 
    return target; 
} 

// For my use case, I always animate via push. Could modify this to pop/push as appropriate 
- (void) switchToViewController:(UIViewController *)target identifier:(NSString *)identifier { 
    [self setViewControllers:[self.viewControllers filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"restorationIdentifier != %@", identifier, nil]] animated:NO]; 
    [self pushViewController:target animated:YES]; 

} 

はちょっと非常に醜い私が(1を探してここに来た)、より良い答えを見つけることを望んで...私は知って回避します。 :-)

+0

ありがとう!それは素晴らしい作品です。しかし、これが将来的にストーリーボードで直接行うことができることを願っています。 :-) – beta

関連する問題