Navigate to another view controller from a popup view - iphone

I have a table in my pop up view. But when clicking on a table row, it doesn't navigate to another view controller. Is there any direct method to navigate from popup view to another view controller ?
thanks in advance.
Code::
ProductListView1 *p = [[ProductListView1 alloc]initWithNibName:#"ProductListView1" bundle:[NSBundle mainBundle]];
[self.navigationController pushViewController:p animated:YES];

Did you try [self presentViewController:p animated:YES completion:nil];
If you don't have a UINavigationController than you can't push a UIViewController.
Also note, that if you push a UIViewController in a UIPopoverController, it will just enlarge the UIPopover. If you want a whole new view to be displayed, than you must use presentViewController: and you could put a UIToolbar to a UINavigationController onto that modal view.

ContentViewController of popover, should be a navigation controller.
First create navigationController with rootViewController as tableViewController(first controller to be displayed in popover)
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:tableViewController];
and then present navigationController in popover
[popOver setContentViewController:navigationController animated:YES];
And then you can push another controller in tableViewController's didSelectRowAtIndexPath: delegate method
ProductListView1 *p = [[ProductListView1 alloc]initWithNibName:#"ProductListView1" bundle:[NSBundle mainBundle]];
[self.navigationController pushViewController:p animated:YES];

Related

Table View presented modally has no navigation bar

When I present a view controller modally:
// Display the nav controller modally.
[self presentModalViewController:theNavController animated:YES];
The navigation bar is covered up the view the pops up!
How can I get the navigation bar to not get covered up??
Thanks in advance!
The answers can be found at iPhone: Show modal UITableViewController with Navigation bar
and
UINavigationBar refuses to show in Modal View Controller!
You need to wrap the UIViewController in a UINavigationController, and then present the navigation controller:
AccountViewController* accountViewController = [[AccountViewController alloc] initWithNibName:#"AccountView" bundle:nil];
...
// Initialize properties of accountViewController
...
UINavigationController* navController = [[UINavigationController alloc] initWithRootViewController:accountViewController];
[self.navigationController presentModalViewController:navController animated:YES];
[navController release];
[accountViewController release];
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewContorller:someViewController];
[self presentModalViewController:navController animated:YES];

how to keep a UINavigationController in a modelView

I am a little confused about the management for UINavigationController to ModelView. I am having an UINavigationController in the RootView, and I want to popup another modelView from bottom to up based on RootView and in the meanwhile keep the NavigationController stays in the modelView so that I could still navigate to the next. How to implement that?
you can create your navigation controller in the RootView. Suppose you want to display modal view on button click in RootView :
- (IBAction) showModalView
{
YourModalView * aYourModalView = [[YourModalView alloc] initWithNibName:#"YourModalView" bundle:nil];
UINavigationController *navigation = [[UINavigationController alloc] initWithRootViewController:aYourModalView];
aYourModalView.navigationController.navigationBar.hidden = YES ;
[self.navigationController presentModalViewController:navigation animated:YES];
[aYourModalView release];
}
Now, your modal view has navigation controller and you can push VCs from modal view using :
[self.navigationController pushViewController:aViewController animated:YES];
Hope it helps you...
You can use the
- (void)setViewControllers:(NSArray *)viewControllers animated:(BOOL)animated
method on UINavigationController. Just don't animate, and change the object at index 0 of that array to your new RootView.

don't understand how to use navigation controller in iphone

I'm extremly new to iphone and I have the following misunderstanding.
All over internet the tutorials about how to use NavigationController programatically it says:
NavigationController must be declared in applicationDidFinishLaunching and must be init with a root.After that you can add views to it.
I have this:
A UIViewController class meaning(AdiViewController.h, AdiViewController.m and AdiViewController.xib) and no Delegate file meaning no applicationDidFinishLaunching method.
What I wanna do is from my class-AdiViewController when pressing a button to go to another view.
I understand that I need a NavigationController which should retain my views having the root AdiViewController.
But my problem is where should I initializate that NavigationController in viewDidAppear??...cause I don't have the Delegate files.
If you could provide a minimal example with this small issue of mine it would be great.I'm sure that for those how are senior this is nothing but still I don't get it.Thanks
NavigationController must be declared in applicationDidFinishLaunching -> this is not true.
In your AdiViewController if you have button when you push that button you want to load navigation Controller right ?
// Hook this IBAction to your button in AdiViewController
- (IBAction)pushNavController
{
AnotherViewController* rootView = [[AnotherViewController alloc] initWithNibName:#"Anotherview" bundle:nil];
UINavigationController* navController = [[UINavigationController alloc] initWithRootViewController:rootView];
[rootView release];
[self presentModalViewController:navController animated:YES];
[navController release];
}
If you are in AnotherViewController i.e., you are in root view controller of Navigation controller. You need to push and pop view controllers from there. For example if you have a button in AnotherViewController:
// push next view controller onto navigation controller's stack
- (IBAction)pushNextViewController
{
NextViewController* nextView = [[NextViewController alloc] initWithNibName:#"NextView" bundle:nil];
[self.navigationController pushViewController:nextView animated:YES];
[nextView release];
}
// Similarly if you want to go back to AnotherViewController from NextViewController you just pop that from navigation controller's stack
- (IBAction)pushNextViewController
{
[self.navigationController popViewControllerAnimated:YES];
}

Using pushViewController: animated:

I'm trying to use the pushViewController: animated: with a UIViewController. I have it housed in a UINavigationController with initWithRoot and it still doesn't work.
Here is my code? Am I doing something wrong?
CloudappSettingsViewController *cloud = [[CloudappSettingsViewController alloc] initWithNibName:nil bundle:nil];
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:cloud];
[self pushViewController:nav animated:YES];
[cloud release];
It always crashes when it gets up to the [self pushViewController:nav animated:YES];
Any ideas?
Thanks
is "self" a UINavigationController?
It seems you are trying to push the navigation controller, but that is backwards. You should present the navigation controller and push additional views to it.
So the UIView you are in should already be in the nav controller then you would push cloud into that.
If this is in your app delegate, just add the UINavigationController as a subview to your app's window. If you want to present the UINavigationController as a modal view controller then do this:
[self presentModalViewController:nav animated:YES];
It will crash definitely because you set the nib to nil.
CloudappSettingsViewController *cloud = [[CloudappSettingsViewController alloc] initWithNibName:#"NibName goes here" bundle:nil];
Create a nib and assign it to your view controller.

Presented modal navigationcontroller under current navigationcontroller iphone

In my application the modal navigationcontroller that I am presenting is going under the current navigationcontroller so I'm not able to view the new navigationbar as it's disappearing under the current one.
I'm presenting the modalview on self and not self.navigationcontroller because self.navigationcontroller doesn't present the modalviewcontroller.
Also how to push a view on this modal navigationcontroller?
I'm using following code in one of my viewControllers:
fullListTopCompanies *fullListTopCompaniesInstance = [[fullListTopCompanies alloc] initWithNibName:#"fullListTopCompanies" bundle:nil];
UINavigationController *navigationController = [[UINavigationController alloc]
initWithRootViewController:fullListTopCompaniesInstance];
fullListTopCompaniesInstance.navigationController.navigationItem.title = #"F";
[self presentModalViewController:navigationController animated:YES];
[navigationController release];
[fullListTopCompaniesInstance release];
Can anybody please help?
Thanx in advance.
use animated with transition
according to me you have to change the animation style
i done it before but forgot the code i will post it when i get it
self.navigationController.navigationItem.title = #"F";
Add the above line of code in viewDidLoad method of "fullListTopCompanies" class.
Actually your navigation bar hides because of the modal view and modal view by default doesnt have Navigation bar.To add a navigation bar to modal view you can try the below code:
In Header File
IBOutlet fullListTopCompanies *fullListTopCompaniesInstance;
In Implementation File
UINavigationController *nav = [[UINavigationController alloc] initWithNibName:#"fullListTopCompanies" bundle:nil];
[self presentModalViewController:nav animated:YES];
[nav release];
Also on the "fullListTopCompanies" View Controller dont forget to put a left navigation bar button item for dismissing the modal view.
So add that left bar button (Ideally Cancel Button on navigation bar) and event handler for that left barr button should contain the code
[self dismissModalViewControllerAnimated:YES];
Hope this helps.