What does "push a controller onto another controller" mean?
I have a FirstViewController
which is my root navigation controller. I have a compose button and I want to display the TTMessage Composer modally on click. This works fine.
The problem is that there is no navigation bar to cancel the composer, so I have to add one.
This how it looks like without a navigation bar by just presenting the message composer (TTMessageController) 开发者_如何学JAVAmodally.
I found this from three20 google group:
Before you present the message controller, you have to create a navigation controller, push the message controller onto it, and then present the navigation controller modally.
It seems like the solution for my problem but I do not understand it. Can anyone explain it with a little bit of code? I now the navigation controller from the objects panel and I can drag it on my nib files but what does it mean in this case? And what means "push"?
To create a navigation controller using an extant view controller, you can use initWithRootViewController:
UINavigationController *navigationController =
[[UINavigationController alloc] initWithRootViewController:myTTMessageComposer];
If you're just using the navigation bar for "decoration", though (i.e. you wont actually navigate from the message view), you can just add a navigation bar directly to the TTMessageComposer's view.
To learn about view controllers and navigation, read the View Controller Programming Guide for iOS.
精彩评论