Reputation: 1555
I'm new to Objective-C programming and I'm having a little trouble understanding how I transition between two views.
Basically, I have my main view (the view that loads up when the application opens) and I want to transition to a new view on pressing a button. The user will not need to go back to the main view after pressing the button -- it's basically a title screen.
Could someone please briefly explain the steps I would need to take to make this happen?
Thanks a lot.
Upvotes: 1
Views: 362
Reputation: 8243
If you don't just want to copy & paste the code you should follow Apple's sample code step by step and remember you can download it:
ViewTransitions sample application
The ViewTransitions sample application demonstrates how to perform transitions between two views using built-in Core Animation transitions. By looking at the code, you'll see how to use a CATransition object to set up and control transitions.
Upvotes: 0
Reputation: 4169
If it's going to be a modal view, you can push on a new modal view controller which will then later be popped off when work is complete. These are usually intended for small amounts of work
[container presentModalViewController:yourNavigationViewController animated:YES];
Otherwise you can modify the UIView stack using the two UIView transition class methods:
+ transitionWithView:duration:options:animations:completion:
+ transitionFromView:toView:duration:options:completion:
For more info on these check out Apple's UIView
class docs.
Upvotes: 0
Reputation: 47241
You could make use of UIView's class method transitionFromView:toView:duration:options:completion:. A call to switch from viewA to viewB could look like this:
[UIView transitionFromView:viewA
toView:viewB
duration:1.0
options:UIViewAnimationOptionTransitionFlipFromLeft
completion:^(BOOL finished){
[viewA release];
}];
As you mentioned the user won't get back to the mainView I added something to the completion parameter to get rid of viewA afterwards.
You can find the animation options in the constants of the UIView class documentation.
Upvotes: 1