Subscribe to
Posts [Atom]


switch between views with buttons on the iPhone

Saturday, June 06, 2009

This took me a while to figure out (what's new) but I solved the problem by implementing some code in the app delegate based on the following code:

This goes in the app delegate
- (void)flipToTwo {
SecondViewController *aSecondView = [[SecondViewController alloc] initWithNibName:@"SecondView" bundle:nil];
[aSecondView release];

[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.5];
[UIView setAnimationTransition:UIViewAnimationTransitionFl ipFromRight forView:window cache:YES];
[viewController.view removeFromSuperview];
[self.window addSubview:[secondViewController view]];
[UIView commitAnimations];
}

In my main view class i have the following function, this is connected to a button done in interface builder so that when the button is clicked appdelegate is called and dold to flip the view.

- (IBAction)tellDelegateToFlipViewsid)sender {
AncientWisdomAppDelegate *mainDelegate = (AncientWisdomAppDelegate *)[[UIApplication sharedApplication] delegate];
[mainDelegate flipToTwo];

Thanks to genemartone posting this at http://www.iphonedevsdk.com/forum/iphone-sdk-development/4052-have-someone-example-uibutton-switch-view-i-am-despair.html



}

Labels: , , ,


1 Comments:

Blogger Evan said...

Joe. I just figured this out too:

[whippa whip whippa butts: null beep bop poopy pants\"]

Hopefully this helps you, I got it from Mike Kordich, who, as you know, is a programming genius.

L8R Broseph

1:50 AM  

Post a Comment

Subscribe to Post Comments [Atom]

<< Home