My problem is that the subview won't leave the view. Here's my code:
Code in the view controller to be removed. This runs.
-(IBAction)qButtonPressed{
RootViewController *myViewController = [[RootViewController alloc]
init];//WithNibName:@"MainWindow" bundle:nil];
[myViewController removegvView];
[myViewController release];
}
RootVIewController.h
@class GameViewController;
....
GameViewController *gvController;
}
@property (nonatomic, retain)GameViewController *gvController;
-(void)removegvView;
...
RootViewController.m
.....
-(void)loadGvController {
GameViewController *viewController = [[GameViewController alloc]
initWithNibName:@"GameView" bundle:nil];
self.gvController = viewController;
[viewController release];
}
-(void)removegvView{
if (gvController == nil) {
[self loadGvController];
}
UIView *gvView = gvController.view;
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlDown
forView:self.view cache:YES];
[gvController viewWillDisappear:YES];
[gvView removeFromSuperview];
[gvController viewDidDisappear:YES];
[UIView commitAnimations];
//This code runs, but nothing happens.
}
......
It builds without any errors & warnings. I'm stumped.:confused: Any help is
appreciated.
Replies
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomeFirst off, you created gvView in the removegvView method which is an odd place to put it, but since it was never added to a view removing it with removeFromSuperview will probably make things crash at some point.
You need to create gvView somewhere else (loadView is common), then add it to the window or content view or some existing view... after that when you want it to go away you remove it from the superView.
Go to the dev center and grab one of the non-IB based examples on how to put views up programatically. It'll get you miles along your way!
Calc-12E <-- ditch your old calculator.
<a href="htt
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomeThanks for replying!
-(void)gameToggleView{
[self removePGToggleView];
if (gvController == nil) {
[self loadGvController];
}
UIView *gameView = gvController.view;
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.view cache:YES];
[gvController viewWillAppear:YES];
[self.view addSubview:gameView];
[gvController viewDidAppear:YES];
[UIView commitAnimations];
[gvController sGame];
}
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesome