views:

512

answers:

3

I built an application. On the one my views I used TableView. So now I want to change this Table view to a navigation controller.

1- How can I change UITable view to Navigation Controller.؟

A: 

If you have started with one of the template project in XCode find the .xib file for your view and launch InterfaceBuilder by double clicking the .xib file. You can manipulate the view directly by dragging and dropping components as well as adding components from a palette.

I would walk through one of Apples tutorials and get a feel for working with InterfaceBuilder - this tutorial shows adding a view controller.

Niels Castle
i don't get my answer !
Momeks
No really, there is no magic answer... Tear out your UITableView and replace it with a UINavigationController, then readd the UITableView to the UINavigationController.
Niels Castle
+2  A: 

The easiest way to achieve this is to create a new 'Navigation-based Application'. This will set up everything you need. By default this will set you up with simple RootViewController, if you want you can change this to be your TableViewController by editing the application delegate

- (void)applicationDidFinishLaunching:(UIApplication *)application {    

    // Override point for customization after app launch    

    RootViewController *rootViewController = (RootViewController *)[navigationController topViewController];
    rootViewController.managedObjectContext = self.managedObjectContext;

    [window addSubview:[navigationController view]];
    [window makeKeyAndVisible];
}

All you need to do is copy your TableViewController into the new project and change the RootViewController to be yours

Liam
Ok tnx i'll try it !
Momeks
BTW the default navigation app has a TableViewController as the RootController, so just modify it to display the data you need
Liam
OK . i add NavigationController to my AppDelegate.h /.m like navigation app project , then on mainview controller i import NavigationController on mainwindow , i connect my delegate from app delegate , and set nib name my viewcontroller . but sill doesn't work !
Momeks
Dear Liam this is my problem :P can you check it ? http://www.multiupload.com/QAF448G1BW
Momeks
I had a look and changed a few of the files, the main problem was that the mainwindow.xib and delegate were using tring to use a controller it did not need to. Anyway, heres the modified project http://www.filefactory.com/file/a165138/n/NaveTest.zip
Liam
I should add, I only modified the source to get navigation working, I didn't try to fix anything else. Hope that helps
Liam
A: 

Thank you everybody . finally i figured out :D , just put this code :

UINavigationController *myNav=[[UINavigationController alloc] initWithRootViewController:[[YourViewController alloc] initWithNibName:@"YourViewController" bundle:nil]];
    [self presentModalViewController:myNav animated:YES];
Momeks