Use of presentModalViewController

Discussion in 'iOS Programming' started by Hawkeye75, Apr 15, 2010.

  1. Hawkeye75 macrumors member

    Joined:
    Mar 29, 2010
    #1
    Hi folks,

    Quite simply I am creating a game with a Menu screen and 3 "boards" for different difficulties. The idea is that I wanted to add buttons on the Menu screen so that clicking the "Easy Game" would load the "Easy Board".

    Now I know I can use a navigation controller and have a user select a difficulty then click some "Begin" button on a nav bar but that isn't the kind of look I was going for.

    So I came across presentModalViewController and dismissModalViewController. After watching some tutorials these appear that they will do the trick.

    What I want to know if there are any caveats I need to know about and whether or not it is advisable to use for a game? (puzzle)

    I'm trying to be mindful of memory management and the like. When I look at apples documentation -

    http://developer.apple.com/iphone/library/documentation/UIKit/Reference/UIViewController_Class/Reference/Reference.html#//apple_ref/doc/uid/TP40006926-CH3-SW30

    There doesn't seem to be any mention of what happens when the modal view is dismissed. I always nil any objects and release them in the dealloc method of my controller. Does dismissModaViewController call those methods to ensure proper cleanup or does it do it's own cleanup?

    I'm sorry if I'm not 100% clear...I'm still trying to wrap my head around certain concepts. I'll be more than happy to clarify any discussion points.

    Thanks
     
  2. PhoneyDeveloper macrumors 68030

    PhoneyDeveloper

    Joined:
    Sep 2, 2008
    #2
    There's nothing special about memory management for a modal view controller vs other view controllers.

    You can do this with a modal view controller or you can use a navigation controller with a hidden navbar. I recommend you use the hidden navbar.
     
  3. Hawkeye75 thread starter macrumors member

    Joined:
    Mar 29, 2010
    #3
    I've noticed apps many apps that seem to use hidden/transparent nav bars. However these buttons would still be limited to the top or bottom of the screen.
     
  4. PhoneyDeveloper macrumors 68030

    PhoneyDeveloper

    Joined:
    Sep 2, 2008
    #4
    Hidden and transparent are completely different. Hidden means that you can't see it, at all.

    If you use a hidden navbar then you must have your own controls to go 'Back' or forward. You use the navigation controller methods pushViewController: and popViewController in the usual way however to present and remove view controllers and their views from the screen. You can have whatever buttons you like wherever you like on screen to push or pop view controllers.
     
  5. Hawkeye75 thread starter macrumors member

    Joined:
    Mar 29, 2010
    #5
    Ah I see, however pushing the view on the stack seems very similar to calling a modal view. Is it much easier to implement?
     

Share This Page