2009-11-14 28 views
2

我是iphone應用程序開發的新手。 我有一個mainmenu視圖控制器,它有一個登錄按鈕。 一旦我通過調用這個在視圖控制器之間提供轉換

LoginController *lc2=[[LoginController alloc] initWithNibName:@"LoginController" bundle:nil]; 

UINavigationController *navigationController = [[UINavigationController alloc]initWithRootViewController:lc2]; 
[self presentModalViewController:navigationController animated:YES]; 

點擊登錄按鈕i顯示下一個登錄視圖控制器但是,這種觀點似乎來自屏幕的右側,我想提供像,捲曲或翻轉效果,當我從一個視圖控制器導航到另一個。 請幫助我的代碼來提供這種效果

回答

0

也許這樣的事情,從模態視圖控制器的演示代碼分離動畫代碼:

LoginController *lc2=[[LoginController alloc] initWithNibName:@"LoginController" bundle:nil]; 

UINavigationController *navigationController = 
     [[UINavigationController alloc]initWithRootViewController:lc2]; 

[UIView beginAnimations:nil context:nil]; 
[UIView setAnimationDuration:0.75]; 
[UIView setAnimationDelegate:self]; 
[UIView setAnimationTransition: UIViewAnimationTransitionFlipFromRight forView:navigationController.view cache:YES]; 

[self presentModalViewController:navigationController animated: NO]; 
[UIView commitAnimations]; 
+0

感謝您的及時回覆..但我看到的按鈕或顯示效果的標籤,我希望整個頁面,以顯示效果 – shreedevi 2009-11-14 09:44:46

0

我十分luvieere同意,但我認爲,視圖中

[UIView setAnimationTransition: UIViewAnimationTransitionFlipFromRight forView:navigationController.view cache:YES]; 

規定必須是容器視圖,在至極子視圖將被添加或刪除,我不知道,如果是navigationController.view容器視圖。我會嘗試不同的組合,包括self.view,self.view.superview(這取決於「presentModalViewController」的行爲)。

+0

感謝您的及時回覆..但我看到的按鈕或標籤顯示效果,我希望整個頁面,以顯示效果 – shreedevi 2009-11-14 10:52:07

1

檢查來自Apple SDK的節拍器示例。它在這裏發佈的代碼太多了,所以我想指出你的例子。 基本思想是使用父視圖控制器來處理兩個或多個子視圖控制器之間的轉換。這包括建立一個協議,順利地讓子視圖控制器通知根視圖控制器關於要做的轉換。有點模糊,我知道 - 所以請跳入示例代碼。

+0

非常感謝謝謝! 它的工作.... – shreedevi 2009-11-14 17:25:18

相關問題