Modal viewController - iphone

My Question is what is the difference between a ViewController and a Modal ViewController ?
Thanks for your answers,

No difference, except for the way that they're presented. A modal view controller is any view controller that's presented modally, using -[UIViewController presentModalViewController:animated:].

A modal view controller is used (usually) to gather information from the user before resuming operation. Basically, the view shown is only dismissed when the user completes a form or something similar. While shown, the modal view does not allow in any way accessing the other views shown, until it's dismissed.
Full details available here.

Related

PresentModalViewController, PushViewController, then DismissViewController with a new view shown?

I have a UINavigation controller setup. I was hoping to do this:
From one of the views, I presentModelViewController:animated:, the user selects one of three options, after selecting I want the UINavigationController behind the modal view to change (the user will not see this), then I want to dismissModalViewControllerAnimated to reveal the new view.
Is this possible using the built-in modal view? Or will I need to create a view, add/animate it to the rootViewController so its not in the same stack as the UINavigationController?
Thanks!
A modal view is a view you show modally on top of another view to interrupt the user from the current task. If I understand you correctly, you need two modal views and the selection user make on first modal view will decide what will show as the second modal view. Is that right?
If that's the case, you can make your main view to be the delegate of your first modal view, and send data back to the main view when the user makes a selection, and then main view dismiss the modal view (it's the main view's responsibility to dismiss it). And then based on user's input, you create another view and pop it modally. To make it animate correctly, you need to set the animation of the dismissing of the first modal view to be NO, and then make the animation of populating second modal view to be YES.
Hope this helps.

Memory issue in Present Modal View Controller

I am just presenting modal view controllers one after the another and not dismissing that. Because my requirement is such that I want show view controllers one after the another like chain.
1) Will this create memory problem ?
2) If so what is the work around ?
Thanx in advance
Yes you may get a memory or performance problem. I don't think Apple intended/intends for anyone to present multiple modal view controllers one after the other.
Have you seen this : Problem dismissing multiple modal view controllers
I think you should dismiss the current modal before presenting a new one. Always. Always. Always. You don't have to dismiss them animated though, you can dismiss them without animation so you don't see them disappear visually.
If you need to be able to go backwards through the chain of modally presented view controllers then I would instigate a method for doing this. e.g. add properties to your UIViewController subclasses that specify the next and previous viewController (or maintain a history trail of the viewControllers).
To be honest, it sounds like you should be using a navigationController and not presenting the viewControllers modally.

Is there a delegate in the parent view controller that gets called after a modal view gets dismissed?

After a modal view controller is dismissed, is there any delegate method called to bring the parent view controller to the front?
I ended up using delegation from Apple's View Controller Programming Guide for iOS :
http://developer.apple.com/library/ios/#featuredarticles/ViewControllerPGforiPhoneOS/ModalViewControllers/ModalViewControllers.html#//apple_ref/doc/uid/TP40007457-CH111-SW14
When it comes time to dismiss a modal view controller, the preferred approach is to let the parent view controller do the dismissing. In other words, the same view controller that presented the modal view controller should also take responsibility for dismissing it whenever possible. Although there are several techniques for notifying a parent view controller that it should dismiss its modally presented child, the preferred technique is delegation.
There was a good example in the CoreDataRecepies sample code when adding a recipe that fit what I was trying to do.
i.e., at the "same time" view[Will|Did]Disappear: is being called on the modal view controller as its view is being dismissed, the view[Will|Did]Appear: are sent to the view controller that is being revealed
the code in here should not really need to differ from the reveal code you used when it was first displayed,
if you need data passed back from the modal controller to the one that displayed it, generally the code that dismisses the modal controller lets the other one know
parentController.item = self.chosenItem;
[parentController dismissModal…

Dismiss some views

First, sorry about my English, I know it's bad, but I'm trying to make it better...
Here is the issue: I'm making an app, with a view controller, with a lot of views... I want to make a button to go back to the main one. I think I have to dismiss the views I pushed. I dont know if that is necessary or if I can push it again directly. If it is, how can I do that? I've tried to put a dismiss method after the presentModalViewController one, but it didn't work.
Any help?
Thank you so much for your help ;)
It hard to tell from your question, but you may be confused by the navigation stack and the modal controllers.
A modal controller gets presented and dismissed using:
presentModalViewController:animated:
dismissModalViewControllerAnimated:
Navigation controllers are pushed and popped using:
pushViewController:animated:
popViewControllerAnimated:
So make sure you are using the correct method to pop or dismiss the view in question.
To present and dismiss a modal view you'll have to use delegation.
Here is an explanation for how to present and dismiss modal views.
Modal views are handled differently than views controlled by the UINavigationController or UITabBarController, which just push them onto a view stack or array of views.

Understanding View Controllers

I have an TabBar application with 4 tabs. All four tabs have navigation controllers. In the settings tab i have a table with a cell for "Feedback". When the cell is clicked a FeedBackView controller is pushed which contains a feedback form with a few fields. This has a textfield for Category. When the textfield is touched, a modal view controller (FeedBackModalView) is presented with a picker. In the viewDidLoad method of the FeedBackModalView controller I typed NSLog(#"%#", self.parentViewController). In the console it shows the parentViewController as TabBar controller. Why is that? Shouldn't it be showing the FeedBackView controller as the parentView since I'm presenting the modal view in that controller?
I hope i was clear.
Using presentModalViewController with UITabBarController has some issues, and I believe the internal behavior of the method has kept changing in recent SDK versions. The bottom line is, you are supposed to use the root view controller to modally present a view controller. In case you are using tab bar interface, that becomes the UITabBarController object.
In an old version of SDK, when I presented a modal view in a view controller inside a tab bar controller the modal view did not appear in full screen, which wasn't an expected or a documented behavior. Now a modal view seems to appear in full screen anywhere, and I wouldn't be surprised if [self presentModalViewController:animated:] method internally checks self and if it has non-nil parentViewController property, send the message to the parent view controller (which will explain your observation).
My memory is vague and perhaps somebody has to correct me. However, I still believe it's the straightforward thing to understand (and also maybe practice) presentModal... only works with the root view controller.