开发者

provide transitions between view controllers

i am new to iphone application development. I have a mainmenu view controller, which has a login button. once i click the login button i display the next login view controller by calling this

LoginController *lc2=[[LoginController alloc] initWithNibName:@"LoginController" bun开发者_运维问答dle:nil];

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

But this view appears to come from the right side of the screen,i want to provide the effects like, curl or flip,when i navigate from one view controller to another. Please help me with the code to provide this effect


Check the Metronome example from Apple's SDK. Its a bit too much code for posting it right here, hence I would like to point you to that example. The basic idea is using a parent view-controller that handles the transitions between two or more child view-controllers. That involves setting up a protocol for smoothly allowing the child-view-controllers to inform the root-view-controller about transitions to do. Bit vague, I know - so please jump into the example code.


Perhaps something like this, separating the animation code from the modal view controller's presentation code:

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];


I quite agree with luvieere, except I think that the view specified in

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

must be the container view, in wich a subview will be added or removed, and I'm not sure if navigationController.view is the container view. I would try with different combinations, including self.view, self.view.superview (that depends of the behavior of "presentModalViewController").

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜