2011-07-18 75 views
0

尋求幫助。如何刪除以前的ViewController?

我的項目: 我爲孩子做了一本書。 每一頁都是一個自定義的ViewController。 在每一頁上,我都有一個用於下一頁和上一頁的按鈕。 當下一頁按鈕被按下了的AppDelegate我「開關」 /添加一個視圖控制器是這樣的:

- (void)goToNextPage2 { 
self.view2 = [[ViewController2 alloc] init]; 
view2.view.frame = CGRectMake(769, 0, 768, 1024); 
[window addSubview:view2.view]; 
[UIView beginAnimations:nil context:NULL]; 
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut]; 
[UIView setAnimationDuration:0.5]; 
view2.view.frame = CGRectMake(0, 0, 768, 1024); 
[UIView commitAnimations]; 
} 

如何和我在哪裏可以刪除以前的viewController? 在這種情況下,它將是ViewController1。 有什麼想法?

在此先感謝 Planky

+0

你爲什麼要 '刪除' 以前的看法? –

回答

4

您沒有提供太多的信息.​​..
無論如何,這可能幫助。

在您的動畫代碼:

[UIView setAnimationDelegate:self]; 
[UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)]; 

,並添加刪除的ViewController:

- (void)animationDidStop:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context 
{ 
    [self.view1.view removeFromSuperview]; 
    self.view1 = nil; 
} 
+0

你是我的男人/女人!!!!!! 謝謝你的時間。 – Planky

+0

沒問題的隊友!如果它工作正常,你會介意投票嗎? –

+0

我沒有足夠的聲望,對不起。但是當我有足夠的時候我會的。諾言! – Planky