Hi, I'm kinda new here so no flaming or anything please.
anyways, I have a problem I am making a game and as I designed it, I have a splash screen (which is ok) after a few secs The view flips to the main menu.
In the main menu I have a few button (arcade, help, statistics and about), I decided to create the about window first (easiest...).
created an about.nib, and aboutview.m/h and aboutController.m/h, linked everything through IB and added these several lines of code:
-------------------------------------------------------------------------------
- (void)loadAboutView {
aboutViewController *viewController = [[aboutViewController alloc] initWithNibName"about" bundle:nil];
self.about = viewController;
[viewController release];
self.aboutNavigationBar = [[UINavigationBar alloc] initWithFrame:CGRectMake(0.0, 0.0, 320.0, 35.0)];
self.aboutNavigationBar.barStyle = UIBarStyleBlackOpaque;
UIBarButtonItem *buttonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self actionselector(toggleAbout)];
buttonItem.title = @"Back";
UINavigationItem *navigationItem = [[UINavigationItem alloc] initWithTitle"About"];
navigationItem.rightBarButtonItem = buttonItem;
[aboutNavigationBar pushNavigationItem:navigationItem animated:NO];
[navigationItem release];
[buttonItem release];
}
- (IBAction)toggleAbout {
if(about == nil){
[self loadAboutView];
}
UIView *mainView = about.view;
UIView *flipsideView = flipsideViewController.view;
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:2.0];
[UIView setAnimationTransition[mainView superview] ? UIViewAnimationTransitionFlipFromRight : UIViewAnimationTransitionFlipFromLeft) forView:self.view cache:YES];
if ([mainView superview] != nil) {
[flipsideViewController viewWillAppear:YES];
[about viewWillDisappear:YES];
[mainView removeFromSuperview];
[self.view addSubview:flipsideView];
[about viewDidDisappear:YES];
[flipsideViewController viewDidAppear:YES];
} else {
[about viewWillAppear:YES];
[flipsideViewController viewWillDisappear:YES];
[flipsideView removeFromSuperview];
[self.view insertSubview:aboutNavigationBar aboveSubview:mainView];
[flipsideViewController viewDidDisappear:YES];
[mainViewController viewDidAppear:YES];
}
[UIView commitAnimations];
}
-------------------------------------------------------------------------------
in the main menu when I click the about button the View flips into an empty view... any ideas?
if anyone can point out the mistake or give an ex. to a right piece of code - will be most appriciated.
~Thanks in advance.
anyways, I have a problem I am making a game and as I designed it, I have a splash screen (which is ok) after a few secs The view flips to the main menu.
In the main menu I have a few button (arcade, help, statistics and about), I decided to create the about window first (easiest...).
created an about.nib, and aboutview.m/h and aboutController.m/h, linked everything through IB and added these several lines of code:
-------------------------------------------------------------------------------
- (void)loadAboutView {
aboutViewController *viewController = [[aboutViewController alloc] initWithNibName"about" bundle:nil];
self.about = viewController;
[viewController release];
self.aboutNavigationBar = [[UINavigationBar alloc] initWithFrame:CGRectMake(0.0, 0.0, 320.0, 35.0)];
self.aboutNavigationBar.barStyle = UIBarStyleBlackOpaque;
UIBarButtonItem *buttonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self actionselector(toggleAbout)];
buttonItem.title = @"Back";
UINavigationItem *navigationItem = [[UINavigationItem alloc] initWithTitle"About"];
navigationItem.rightBarButtonItem = buttonItem;
[aboutNavigationBar pushNavigationItem:navigationItem animated:NO];
[navigationItem release];
[buttonItem release];
}
- (IBAction)toggleAbout {
if(about == nil){
[self loadAboutView];
}
UIView *mainView = about.view;
UIView *flipsideView = flipsideViewController.view;
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:2.0];
[UIView setAnimationTransition[mainView superview] ? UIViewAnimationTransitionFlipFromRight : UIViewAnimationTransitionFlipFromLeft) forView:self.view cache:YES];
if ([mainView superview] != nil) {
[flipsideViewController viewWillAppear:YES];
[about viewWillDisappear:YES];
[mainView removeFromSuperview];
[self.view addSubview:flipsideView];
[about viewDidDisappear:YES];
[flipsideViewController viewDidAppear:YES];
} else {
[about viewWillAppear:YES];
[flipsideViewController viewWillDisappear:YES];
[flipsideView removeFromSuperview];
[self.view insertSubview:aboutNavigationBar aboveSubview:mainView];
[flipsideViewController viewDidDisappear:YES];
[mainViewController viewDidAppear:YES];
}
[UIView commitAnimations];
}
-------------------------------------------------------------------------------
in the main menu when I click the about button the View flips into an empty view... any ideas?
if anyone can point out the mistake or give an ex. to a right piece of code - will be most appriciated.
~Thanks in advance.