Given your question is specific to Apple iOS I will refer to the Human Interface Guidelines (HIG):
Use a modal view when you need to offer the ability to accomplish a
self-contained task related to your app’s primary function. A modal
view is especially appropriate for a multistep subtask that requires
UI elements that don’t belong in the main app user interface all the
time. Which is very similar to Michael's first paragraph.
Further:
A navigation bar enables navigation through an information hierarchy
and, optionally, management of screen contents.
As such, you can have a navigation hierarchy when presenting a modal view. The modal, to try and sum it up, is a way to step out of the normal flow of the app so the user can accomplish something prior to continuing on their way. In the example of a login screen, it makes more sense (based on the HIG), to present it modally, then dismiss it to return the user to the view from whence they came.
For example, go to the Settings app -> Mail -> Add new account (all presented via a navigation hierarchy) - choose one of the providers and a "login page" is presented, modally. Once you fill it out and the whole thing is confirmed, the modal disappears and you are back to your account list. Another example is in the Calendar app, when you add an event, which takes you out of the process of viewing events, the view is presented modally - when you go to assign a calendar, however, the view is presented hierarchically.
When reviewing apps for "how should I do this" - I typically look to those apps created by Apple first, not other developers, because many of us (the royal us) tend to neglect things like the HIG and Apple recommendations; however, Apple tends to be pretty consistent.
To try and encapsulate all of that succinctly. Read the HIG; memorize it; print it out and, if after a few months it's not heavily worn, something is wrong (that's a paraphrase from Apple). When looking to other apps for "advice" on how to handle certain interactions, look at the apps created by Apple first, because they pretty much follow the HIG - and, there are a variety of experiences used not just the standard UI elements.
Hope that helps.
RE: The follow-up question in the Comments
There isn't anything in the HIG that reccomends anything regarding modals inside of modals; however, if you look at the Contacts app, you see the following:
- Add a contact (presents modal),
- Choose add photo (presents action sheet) to either take a photo or choose from your library,
- Either option will present another modal (the Camera app or the Photo Library portion of the Photos app, respectively).
So, assuming Apple adheres to their own UX philosophies, then the answer would appear that it is okay to have multiple modals presented over time; so long as canceling or saving from all of them will lead the user back to the start of the flow.