0
votes

UDPATED WITH FIRST SUGGESTION BELOW, STILL EXPERIENCING ISSUE: I inherited some iPhone apps from a developer, and now I'm the developer with very few skills. I'm trying to convert one of these iPhone apps to universal (iPhone & iPad), and I'm nearly there, just one issue: I have a view that correctly disappears on the iPhone, but not on the iPad. Hoping someone here can help me, I've been struggling with this one issue (which hopefully has a fairly simple solution) for 3+ days, and I think I've pulled all my hair out. :)

I've been told some of this is old code, and that may be true, but because this one issue is blocking me from submitting to the app store, I'd rather avoid big refactoring/redesign solutions for now. So here's what's going on (apologies in advance for the funky formatting on this post, not sure why code isn't all going in the coding format, funky bullet numbering, etc):

  1. App starts from my main view controller (MyAppViewController), which has a "Play" button which starts gameplay. When the "Play button is tapped, the following code instantiates the gameplay view controller:

    mainGameViewControllerIpad = [[MainGameViewControllerIpad alloc] initWithNibName:nil bundle:nil]; [self.view addSubview:mainGameViewControllerIpad.view];

This opens up the view MainGameViewControllerIpad, and the user plays the game.

  1. Once the game round ends, the code in MainGameViewControllerIpad does this:

    GameStatsViewControllerIpad *gameStatsViewControllerIpad = [[GameStatsViewControllerIpad alloc] init]; [gameStatsViewControllerIpad setModalTransitionStyle:UIModalTransitionStyleCrossDissolve]; [self presentModalViewController:gameStatsViewControllerIpad animated:YES];

    [self.view addSubview:gameStatsViewControllerIpad.view];

    [gameStatsViewControllerIpad setStatsDisplay];

This opens up the Game Stats view, which tells the user how they did on the round they just played. So you have the intro screen view, then the gameplay view controller as a subview of that, and the stats screen as a subview of the gameplay view. This works fine on both iPhone and iPad.

So here's where things get weird:

  1. When the user is done viewing their stats, they tap the "done" button on the stats page, and the following code runs:

[self dismissViewControllerAnimated:YES completion:nil]; [self.view release];

SO HERE'S THE ISSUE: on the iPhone, this closes the Stats view, and I'm assuming that because the stats view is a subview of the MainGameViewController, that view disappears as well, and the user is returned to the MyAppViewController. THIS IS CORRECT.

However, on the iPad, when the above code runs, it closes the immediate Stats view, but once it's gone, it reveals that the MainGameViewController view is still visible -- in other words, on the iPhone, the code above closes the subview and it's container view, but on the iPad, it doesn't close the parent/Super view.

Anyone have any fairly simple suggestions on how to get the MainGameViewController to also work on the iPad? Thanks in advance for any insight/suggestions!

1

1 Answers

0
votes

Just dismiss the modal view rather than removing it.

[self dismissViewControllerAnimated:YES completion:nil];