我有一个有4个视图的应用程序; HomeView,PreGameView,GameView,PostGameView。该应用程序的工作方式,我开始在HomeView上,然后点击开始,这将我带到PreGameView,单击开始,这将我带到GameView,在结束游戏,它将我带到PostGameView,从中我可以回去到GameView或返回到HomeView。正确使用presentModalViewController?帮帮我?
我通过使用“presentModalViewController”方法对这些视图进行分层。但是,当我一直下到PostGameView,然后决定返回到HomeView时,屏幕变白。
我也尝试过在推出下一个模型之前解雇每个模型视图,但那不起作用,应用程序变得混乱。有谁知道这样做的正确方法?请帮忙?
HomeView.m
- (IBAction)loadPreGameView:(id)sender {
PreGameView *preGameView = [[PreGameView alloc] initWithNibName:nil bundle:nil];
[self presentModalViewController:preGameView animated:YES];
}
PreGameView.m
- (IBAction)loadGameView:(id)sender {
GameView *gameView = [[GameView alloc] initWithNibName:nil bundle:nil];
[self presentModalViewController:gameView animated:NO];
}
GameView.m
- (IBAction)loadPostGameView:(id)sender {
PostGameView *postGameView = [[PostGameView alloc] initWithNibName:nil bundle:nil];
[self presentModalViewController:postGameView animated:NO];
}
PostGameView.m
- (IBAction)loadGameView:(id)sender {
GameView *gameView = [[GameView alloc] initWithNibName:nil bundle:nil];
[self presentModalViewController:gameView animated:NO];
}
- (IBAction)loadHomeView:(id)sender {
HomeView *homeView = [[HomeView alloc] initWithNibName:nil bundle:nil];
[self presentModalViewController:homeView animated:NO];
}
我也试过下面我PostGameView.m,但它只是表明它背后的GameView:
PostGameView.m(旧)
- (IBAction)loadGameView:(id)sender {
GameView *gameView = [[GameView alloc] initWithNibName:nil bundle:nil];
[self presentModalViewController:gameView animated:NO];
}
- (IBAction)loadHomeView:(id)sender {
[self dismissModalViewControllerAnimated:YES];
}
但是当我做'[self dismissModalViewControllerAnimated:NO]; GameView * gameView = [[GameView alloc] initWithNibName:nil bundle:nil]; [self presentModalViewController:gameView animated:NO];'在PreGameView.m中 - 视图只是从PreGameView回到HomeView,而不是GameView。 – buzzkip 2011-05-02 18:24:31