You connect to things in IB by using
IBOutlet UIView *myView;
or
@property (nonatomic, retain) IBOutlet UIView *myView;
in your header file. The IBOutlet
keyword tells IB to make that outlet available to connect.
You make the actual connection in the Connection inspector by dragging from the outlet to the view:
(Do this for both your views.)
Note: your views don't have to be inside the window in IB. You can create them outside, and they won't be displayed until you want them to. You might want to put one of them in so it shows up when your app launches.
Then, when you actually want to flip to the other view, assuming you're using iOS 4.0, it's simple (there are methods for 3.x and lower, but this is the easiest):
[UIView transitionFromView:myView1
toView:myView2
duration:0.2
options:UIViewAnimationOptionTransitionFlipFromRight
completion:^{
// something to do when the flip completes
}];
Or, if you want to dynamically determine which view is already visible:
UIView *oldView, *newView;
UIViewAnimationOptions transition;
if (myView1.superview) { // view 1 is already visible
oldView = myView1;
newView = myView2;
transition = UIViewAnimationOptionTransitionFlipFromRight;
} else { // view 2 is visible
oldView = myView2;
newView = myView1;
transition = UIViewAnimationOptionTransitionFlipFromLeft;
}
[UIView transitionFromView:oldView
toView:newView
duration:0.2
options:transition
completion:^{
// something to do when the flip completes
}];