How to push a UIViewController from a modal view - iphone

I present a UIViewController modally but would like to push another ViewController from the modal view. How can this be done as pushViewController does not work from a modal view. Thanks

Use a UINavigationController as the view that you show modal. You can then push onto that controller.

I have used a slightly different approach than Mike's suggestion. I create a navigation controller (NC) and init it with a root viewcontroller of the view controller (VC) I want to present modally. I then present the nc modally. I can then successfully push from the VC when needed.

Related

iPhone dismissing multiple controllers?

I suspect many have had this case - you present modal view controller, which then present navigation view controller, that has many table view controllers pushing onto the stack. Basically, pushing and presenting controllers. When you get to last you have to dismiss them all, and return to root view controller
Do i have to call for every modal controller dismiss, and for every pushed controller pop, or is there a better way to do this?
I am using iOS5 storyboards if that is relevant somehow.
EDIT:
Thanks for answes but its little more complicated than that - basically i present modal view controller from root controller, than push couple of controllers, then present one more modal view. At that time I want to go to root controller. So just poping view controllers want do it, some of them have to be dissmised
You can return back to the root navigation controller by calling:
[self.navigationController popToRootViewControllerAnimated:YES];
And then release your modal view controller

How can i dismiss modalViewController without leaving current view?

My application is view based app. First view is login view. After login view i have MainMenuCcontroller which has a tabBarController:
#interface RunnoMainMenuController : UIViewController {
IBOutlet UITabBarController *tabBarController;
}
From login view controller, i am going to MainMenuController using this line of code:
[self presentModalViewController:mainMenu animated:YES];
this controller has 4 tabs. Now i need to do some stuff in viewWillAppear of a tabBarItem. viewWillAppear is not called when i tap a tabBarItem. I have a button in one of those tabBarItem's view which pops up a table view controller using presentModalViewController. This tableView uses dismissModalViewControllerAnimated:YES to disappear it. When i pop up this tableview and dismiss it then viewWillAppear of every tabBarItem works fine. If i will dismiss modalViewController in MainMenuController then it will again go back to login view. How can i dismiss modalViewController without leaving current view or any other solution? Thanks in advance.
You may need to consider how your views are presented. The tab bar controller should always be the window's root view controller. From the Apple docs:
When deploying a tab bar interface, you must install this view as the
root of your window. Unlike other view controllers, a tab bar
interface should never be installed as a child of another view
controller.
Rather than present your login view as the root view and the tab bar as a modal view controller, try it the other way round. The tab bar controller as root, with the login view as presented as a modal view controller from the view controller of whichever tab is shown initially. Dismissing this will then reveal the tab bar controller.

pushViewController from modalViewController

If I push a view onto a navigationController and present it modally, is it possible to push and show another view without having to first dismiss the modalViewController? Thanks.
Your question is not quite clear. "push a view onto a navigationController" and "present it modally" are 2 different operations. However, after doing either of these, you can do either of those again.
NavCon push ViewA
-ViewA can then push ViewB
or
-ViewA can present ViewB modally.
NavCon show ViewA modally
-ViewA can then push ViewB // this is a little weird, but possible.
or
-ViewA can present ViewB modally.

Push UITabViewController from UIViewController is possible?

my app first viewController is UIViewController.
and when user click button firstView disappear and push UITabViewController
is it possible?
i can't find how to push UITabViewController from UIViewController.
UPDATE sorry, I misread TabVC for UITableViewController. Do you mean UITableViewController or UITabBarController? I'll leave my answer below anyways.
In this instance, it's usually best to have a UITabBarController be the root view object. Although it can be done, it's a messier implementation, in my opinion.
I would in fact make the UITabBarController the root and display the UIViewController modally from that UITabBarController on launch.
The user would be presented with the UIViewController and when they clicked the button, dismiss that modal view, revealing the UITabBarController.
Just use a UINavigationController.
Use the navigation controller to push the tableView as the second level in the hierarchy. As a bonus you'll get the back button for 'free' and you don't have to worry about delegates for getting back to the original UIViewController.
you may try this:
self.tabBarController.selectedViewController
= [self.tabBarController.viewControllers objectAtIndex:2];
it should work because selectedViewController property contains view of selected tab.
First of all you have view controller . And make Second view controller which contain tabbarcontroller . Now just push second view controller . And add tabbarcontroller's view as a subview to second view controller .
Hope you gets it ..

UINavigationView in modal view

I would like to place a UINavigation View within a Modal view but I am having loads of problems. I managed to get the modal view working, but when trying to put a UINavigationController in it it just comes up with a blank screen.
Does anybody know how to do that properly?
Create a UINavigationController, initialize it with your UIViewController at its root, and then present the navigation controller modally.