Nav. App Help

Discussion in 'iOS Programming' started by iLoveDeveloping, Dec 4, 2009.

  1. macrumors regular

    Joined:
    Sep 24, 2009
    Location:
    Ireland
    #1
    Hey,

    Just have a quick question, I have a new app made with "Navigation Based Application", but i would like to put a new View in the beginning when it starts!
    So it launches, First screen - View - then press a button and it goes to - The Nav Screen - or back again..

    Now its my understanding you can change the way the App launches with the
    Code:
    - (void)applicationDidFinishLaunching:(UIApplication *)application {
    Am i right or wrong? But everything i try seems to still launch the App with the Nav screen not the View i made.. This is the code i have in the App... Any help?

    Code:
    #import "TestAppDelegate.h"
    #import "TestViewController.h"
    #import "RootViewController.h"
    
    
    @implementation TestAppDelegate
    
    @synthesize viewController;
    @synthesize window;
    @synthesize navigationController;
    
    
    #pragma mark -
    #pragma mark Application lifecycle
    
    - (void)applicationDidFinishLaunching:(UIApplication *)application {    
    	[window addSubview:viewController.view];
            [window makeKeyAndVisible];
        // Override point for customization after app launch    
    
    	[window addSubview:[navigationController view]];
    	[window makeKeyAndVisible];
    
    }
    
    
    - (void)applicationWillTerminate:(UIApplication *)application {
    	// Save data if appropriate
    }
    
    
    #pragma mark -
    #pragma mark Memory management
    
    - (void)dealloc {
        [viewController release];
    	[navigationController release];
    	[window release];
    	[super dealloc];
    }
    
    @end
    Thanks!
     
  2. Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #2
    Is viewController for this new view? If so, you are adding it's view as a subview and then going ahead and adding the navigationController's view right over top of it.

    Here's what I suggest you do: use presentModalViewController: with your viewController after having added navigationController's view.
     
  3. thread starter macrumors regular

    Joined:
    Sep 24, 2009
    Location:
    Ireland
    #3
    Yes viewController is the new View.

    Oh i see, didn't even notice i was doing that... Ok i will have a try.
     
  4. thread starter macrumors regular

    Joined:
    Sep 24, 2009
    Location:
    Ireland
    #4
    ok, very newbie help needed here... (i am sorry! :eek:) Where do i put the code?

    Code:
    presentModalViewController:viewController
    I put it in the AppDelegate and it terminated due to an uncaught exception..

    I need a 'method signature' i think, does that go in the .h Delegate? what would that be?
     
  5. Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #5
    Reread my post, especially the last five words of it.

    Sorry, that's not how you call it. Please read the UIViewController documentation for the proper usage of presentModalViewController:animated:. For one, it's an instance method, which means you need to call it on an instance of UIViewController.

    Are you sure you understand the basics of Objective-C enough to continue with the real coding?
     
  6. thread starter macrumors regular

    Joined:
    Sep 24, 2009
    Location:
    Ireland
    #6
    No i don't really understand where to put it to be honest! I read the documentation but still don't no what to put where? I always just either used View controllers or nav views, never both, so i don't really have any experience on putting one into the other..

    Any help anyone could give me would be very appreciated, i am still learning very slowly... :eek:
     
  7. Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #7
    That help?
     
  8. thread starter macrumors regular

    Joined:
    Sep 24, 2009
    Location:
    Ireland
    #8
    Oh i know where to put it, i don't know however what to put, everything i try i just get a new error...
    Code:
    	// Override point for customization after app launch    
    		[window addSubview:[navigationController view]];
    		[window makeKeyAndVisible];
    		// This is after
    		presentModalViewController:(viewController *) animated:YES;
    	}
    closest i got so far... :confused:



    Or do i put the full line:

    Code:
    - (void)presentModalViewController:(UIViewController *)modalViewController animated:(BOOL)animated
    But still get an error
     
  9. Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #9
    Yes. Sorry but it's pretty obvious you have no clue how to properly call an instance method. Leave the real code alone and go learn Objective-C.
     
  10. thread starter macrumors regular

    Joined:
    Sep 24, 2009
    Location:
    Ireland
    #10
    If you don't want to help me anymore then giving me a link then that's fine, i am simply asking for help cos i DO NOT KNOW what to do with that information...

    If you told me how to do it then you would have thought me and i would then never have to ask how to call an instance method again cos i could do it from then on, itsn't that how people learn?!

    Whats the difference between someone telling me and learning how to do it from that or looking in a book and learning that way... Both the same to me..

    Just asking for help thats all...


    So can anyone give me more information?
     
  11. Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #11
    It's hard to help those who don't help themselves.

    Start here, paying special attention to the link to Cocoa Dev Central.
     
  12. macrumors regular

    Joined:
    Mar 30, 2008
    Location:
    Uppsala, Sweden
    #12
    I agree with dejo, you really need to understand the programming language before starting developing your application. I recommend this Objective-C manual from Apple.
     
  13. Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #13
    What's kinda scary is that besides iChocolate (the app that ILoveDeveloping links to in his profile), he has 10 other apps on the App Store. All without knowing how to construct an instance method call.

    Another good resource. Can seem a little daunting when you first are learning Objective-C but once you're more comfortable with things, rereads are easier.
     

Share This Page