iPhone SDK - How to use presentModalViewController and keep the Title Bar

Discussion in 'iPhone/iPad Programming' started by maxjg, Apr 17, 2008.

  1. macrumors member

    Joined:
    Aug 6, 2006
    #1
    Hello guys,
    Been messing with this one for a while, still haven't been able to figure it out. I'm trying to use presentModalViewController, and can get it to mainly work, but I need to keep the title bar. I have, so far, been unable to do so. I've tried giving the view controller it's own UINavigationController, and still, no luck.
    Any ideas?

    Max
     
  2. macrumors 6502

    Joined:
    Mar 31, 2005
    Location:
    London, England
    #2
    This is the right approach. Did you make sure to pass the UINavigationController itself to -presentModalViewController:animated:?
     
  3. macrumors 6502a

    Joined:
    Nov 18, 2007
    #3
    did anyone else figured this out? You cant pass UINavigationController to -presentModalViewController:animated:
     
  4. thread starter macrumors member

    Joined:
    Aug 6, 2006
    #4
    Think I saw somewhere that Apple's not allowing you to do this in the beta, or something to the same effect.
     
  5. macrumors 6502a

    Joined:
    Nov 18, 2007
    #5
    maxjg how did you get around it in the end?
     
  6. thread starter macrumors member

    Joined:
    Aug 6, 2006
    #6
    Never did. Even in Apple's examples for the SDK, where, in real contexts, they would use presentModalViewController, they instead use pushViewController. I guess we'll just have to deal with it(or hack our way around it). If I make any sudden discoveries, I'll post them here.
     
  7. macrumors 6502a

    Joined:
    Nov 18, 2007
    #7
    but if you look at the mail app, compose mail modal view clearly has it
     
  8. macrumors regular

    Joined:
    Mar 27, 2008
    #8
    What current apple-created applications are doing and what they are "allowing" us to do through the supplied SDK are two completely different things. They are putting a double standard on us so that they can keep the illusion of security in one of their now-landmark products. If you want to circumvent the SDK and do whatever you wish then you will need to look into unlocking and jailbreaking your phone. Then you will be able to have full access to any and all object frameworks available on the phone itself. This will have no official support and documentation of course unless some users of this method decide to produce it for you.
     
  9. macrumors 6502

    Joined:
    Mar 31, 2005
    Location:
    London, England
    #9
    Something doesn't work quite right in a beta version of a new framework. It's a bloody conspiracy...
     
  10. macrumors 6502

    Joined:
    Feb 16, 2007
    Location:
    Waterloo, Ontario
    #10
    You definitely can pass a navigation controller to presentModalViewController:animated:. Below is the sample code from one of my apps (using UIViewController instead of my class name). Make sure your view controller is a subclass of UIViewController and the method should take it.

    Code:
    if (navigationController == nil) 
    {
    	if (rootViewController == nil)
    	{
    		rootViewController = [[UIViewController alloc] init];
    	}
    	navigationController = [[UINavigationController alloc] initWithRootViewController:rootViewController];
    }
    [[self navigationController] presentModalViewController:navigationController animated:YES];
    
    BTW: this is called from a view controller that is already on another navigation controller.
     
  11. macrumors 6502

    Joined:
    Oct 21, 2007
    #11
    Has this issue been resolved for you guys? I was struggling with this for an hour or two and then I looked at the BonjourWeb example from the Apple Dev Center and I figured it out. If people want me to, I'll post up some code once it get it 100% working...
     
  12. macrumors member

    Joined:
    Jan 3, 2008
    #12
    If you can post a sample that would be great. I also wasted a couple hours on this. Most of the problem is poor documentation and not enough samples code so the support from this forum is really beneficial.
     

Share This Page