雖然所有其他答案都很好,但在我看來,問題是您是否應該從B
推到另一個副本。對於我來說,這是通過你是否想從一個B
跳到前面的B
的問題來回答的。如果是這樣,那很好,並且當您想返回到A
時,使用其他popToRootViewControllerAnimated
或popToViewController
答案中的一個。
如果不是,你根本不應該從B
推到自己的另一個副本。但是,如果您想讓用戶演示「讓我們再次使用」按鈕,您可以使用transitionWithView
。例如,如果我們假設你有一堆UITextField
控制在B
和你有一個「添加另一個」按鈕,它可以做到以下幾點:
- (IBAction)onPressAddButton:(id)sender
{
// save the record here
// now, let's animate the resetting of the text fields
[UIView transitionWithView:self.view
duration:0.5
options:UIViewAnimationOptionTransitionCurlUp
animations:^{
self.textField1.text = nil;
self.textField2.text = nil;
self.textField3.text = nil;
}
completion:nil];
}
而且,順便說一句,如果你這樣做此方式,你現在不需要做任何事情就可以從B回到A.標準導航欄可以滿足我們需要的一切。
來源
2013-01-24 15:03:07
Rob
@ edzio27:另外,如果你有多個A控制器堆棧,你想彈出以後推A,那麼你需要以相反的順序遍歷循環(你需要使用for/while循環)。 –
謝謝Ishu,爲此。我也在這個主題找到幫助http://stackoverflow.com/questions/2099319/how-to-remove-a-particular-view-controller-from-uinavigationcontroller-stack – edzio27