PDA

View Full Version : navigate in & around xib files




ilx.mac
Apr 9, 2009, 04:02 AM
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!



CocoaPuffs
Apr 9, 2009, 04:31 AM
Instance of UINavigationBar should be stored within App Delegate, and you should push the view from that instance.

Thus your code:
[self.navigationController pushViewController:searchAthletesVC animated:YES];
Suggests that you are not doing that. Perhaps what you are looking for is modal view:
- (void)presentModalViewController:(UIViewController *)modalViewController animated:(BOOL)animated

ilx.mac
Apr 9, 2009, 04:51 AM
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?

ilx.mac
Apr 9, 2009, 06:35 AM
I tried using this,

modalViewController = [[WebBrowserTutorialAppDelegate alloc] initWithNibName:@"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!

ilx.mac
Apr 9, 2009, 08:19 AM
Some one help me how to use the appdelegate method please!!!!!!

I am struck!

caveman_uk
Apr 9, 2009, 09:31 AM
Instance of UINavigationBar should be stored within App Delegate, and you should push the view from that instance.

Thus your code:
[self.navigationController pushViewController:searchAthletesVC animated:YES];
Suggests that you are not doing that. Perhaps what you are looking for is modal view:
- (void)presentModalViewController:(UIViewController *)modalViewController animated:(BOOL)animated
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.

ilx.mac
Apr 9, 2009, 09:40 AM
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!

caveman_uk
Apr 9, 2009, 09:41 AM
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].

CocoaPuffs
Apr 9, 2009, 10:50 AM
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.

I figured he's using it everywhere. If he is just trying to navigate between two view, modal view is simpler.

ilx.mac
Apr 10, 2009, 02:52 AM
Thanks for the inputs guys. I made it to work after a days effort using the tutorial @

http://www.iphonesdkarticles.com/2008/08/uiwebview-tutorial.html

And this is one of the best references.