navigate in & around xib files

Discussion in 'iOS Programming' started by ilx.mac, Apr 9, 2009.

  1. ilx.mac
    Expand Collapse
    macrumors member

    Joined:
    Mar 10, 2009
    #1
    Hi there,

    I used the code below to navigate between UITableViewController.

    SearchAthleteNameViewController *searchAthletesVC = [[[SearchAthleteNameViewController alloc] initWithNibName:storyLink bundle:nil] autorelease];
    [self.navigationController pushViewController:searchAthletesVC animated:YES];

    Where SearchAthleteNameViewController is an instance of another UItableViewController (another .xib file).

    Now, I have to navigate to NSObject from an UItableViewController. I tried using the same, i cannot find the method, initwithNibName to make it navigate. And also it shows an warning in the next line & a cfrunloop prevails.

    can some one suggest/send sample code for me to make it run? Please!
     
  2. CocoaPuffs
    Expand Collapse
    macrumors 68010

    Joined:
    Aug 23, 2008
    #2
    Instance of UINavigationBar should be stored within App Delegate, and you should push the view from that instance.

    Thus your code:
    Code:
    [self.navigationController pushViewController:searchAthletesVC animated:YES];
    Suggests that you are not doing that. Perhaps what you are looking for is modal view:
    Code:
    - (void)presentModalViewController:(UIViewController *)modalViewController animated:(BOOL)animated
     
  3. ilx.mac
    Expand Collapse
    thread starter macrumors member

    Joined:
    Mar 10, 2009
    #3
    Thanks For the response CocoaPuffs. you are right, But I am a very very newbie to what u said. Can you please explain me in brief if time permits/ can you send me some code samples for the same? Please!!!

    Also, the particular line:

    Instance of UINavigationBar should be stored within App Delegate, and you should push the view from that instance.

    its new to me.

    Also, i am performing this action (moving inbetween the xib's) in a tableview's didSelectRowAtIndexPath method.

    Can you please guide me?
     
  4. ilx.mac
    Expand Collapse
    thread starter macrumors member

    Joined:
    Mar 10, 2009
    #4
    I tried using this,

    modalViewController = [[WebBrowserTutorialAppDelegate alloc] initWithNibName:mad:"MainWindow_webbrowser" bundle:nil];

    but i am not able to get the method, initWithNibName. if i override that, no warning appears. but ends the app due to uncaught exception.

    please help me!
     
  5. ilx.mac
    Expand Collapse
    thread starter macrumors member

    Joined:
    Mar 10, 2009
    #5
    Some one help me how to use the appdelegate method please!!!!!!

    I am struck!
     
  6. caveman_uk
    Expand Collapse
    Guest

    caveman_uk

    Joined:
    Feb 17, 2003
    Location:
    Hitchin, Herts, UK
    #6
    You don't need to access the appDelegate at all to do what he's doing. It's perfectly fine to use self.navigationController in this way.

    The problem is then navigating to an NSObject - the question is why on earth would you want to? The only things you should be pushing are UIViewController subclasses.
     
  7. ilx.mac
    Expand Collapse
    thread starter macrumors member

    Joined:
    Mar 10, 2009
    #7
    Thanks for the post caveman_uk.
    Still I am struck.

    [self.navigationController pushViewController:searchAthletesVC animated:YES];

    is not helping me right now. Also it says, Warning:passing 2 of
    'initnibname:bundle:' makes pointer from integer without a cast


    in :

    ProfileViewerController *newprofiler = [[[ProfileViewerController alloc] initWithNibName:storyLink bundle:YES] autorelease];

    the profileviewercontroller is an instance of a uiview xib file.

    I cant find the cause of the error still.

    Can you please help me on this/ Please!
     
  8. caveman_uk
    Expand Collapse
    Guest

    caveman_uk

    Joined:
    Feb 17, 2003
    Location:
    Hitchin, Herts, UK
    #8
    The nib name needs to be a string - hopefully storyLink is an NSString?

    bundle: isn't a boolean...it's should most likely be [NSBundle mainBundle].
     
  9. CocoaPuffs
    Expand Collapse
    macrumors 68010

    Joined:
    Aug 23, 2008
    #9
    I figured he's using it everywhere. If he is just trying to navigate between two view, modal view is simpler.
     
  10. ilx.mac
    Expand Collapse
    thread starter macrumors member

    Joined:
    Mar 10, 2009
    #10

Share This Page