Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I have discovered a solution to my problem. Its a bit dirty, (and I''ll probably get shot down in flames for it) but works very well under tests and is very quick to implement. Here's how I did it.</p> <p>In my app I have a Singleton class called <strong>GlobalVars</strong> (I use this for storing various global settings). This class holds a boolean called <strong>home_pressed</strong> and associated accessors (via synthesise). You could also store this value in the application delegate if you wish.</p> <p>In every view controller with a main menu button, I wire the button to the <strong>homePressed</strong> IBAction method as follows. First setting the global <strong>homePressed</strong> boolean to <strong>YES</strong>, then dismissing the view controller in the usual way, but with <strong>NO</strong> animation.</p> <pre><code>-(IBAction) homePressed: (id) sender { [GlobalVars _instance].homePressed = YES; [self dismissModalViewControllerAnimated: NO]; }//end homePressed </code></pre> <p>In every view controller except the main menu I implement the <strong>viewDidAppear</strong> method (which gets called when a view re-appears) as follows.</p> <pre><code>-(void) viewDidAppear: (Bool) animated { if ([GlobalVars _instance].homePressed == YES) { [self dismissModalViewController: NO]; } else { //put normal view did appear code here/ } }//end viewDidAppead </code></pre> <p>In the <strong>mainMenu</strong> view controller which is the <strong>root</strong> of the app, I set the global <strong>homePressed</strong> boolean to <strong>NO</strong> in its view did appear method as follows</p> <pre><code>-(void) viewDidAppear: (Bool) animated { if ([GlobalVars _instance].homePressed == YES) { [GlobalVars _instance].homePressed == NO; } else { //put normal view did appear code here/ } }//end viewDidAppear </code></pre> <p>There, this enables me to go back to the root main menu of my app from any view further down the chain.</p> <p>I was hoping to avoid this method, but its better than re-implementing my app which is what I'd have to do if I wanted use the UINavigationController solution.</p> <p>Simple, took me 10 minutes to code in my 9 view app. :)</p> <p>One final question I do have, would my solution be OK with the HIG?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload