简体   繁体   中英

What is “pushing” a view controller?

I realize this is an incredibly obvious question, but I think that not understanding the answer exactly is hindering me from using Stack Overflow well. I keep seeing the term used in answers and thinking I understand what it means but then I see it in a different answer and think it must mean something different.

The specific context I'm asking in is this, all of which I've done using the Interface Builder:

I wrote a single view app using a toolbar to navigate between a few screens but put all the UI elements on the same view and all the methods in the same view controller. That got really messy.

Then I started from scratch using a tabbed application with storyboards, and now each screen has its own view and view controller. This seems much cleaner, but I hate the way the tab bar looks.

So I'm trying to figure out how to do it yet again using a toolbar but this time switching between different views/view controllers for each screen. And I'm thinking that understanding what "pushing" view controllers means will help me find the answer.

Thanks for your patience with such a basic question.

"Pushing" refers specifically to adding a view controller onto the stack of a navigation controller, which causes that controller's view to slide onto the screen from the right (if it's animated). Some people on SO use the term loosely (incorrectly, I'd say) to mean just getting a controller on screen.

"Pushing" a view controller is typically used in the context of a navigation controller ( UINavigationController ). You start with the root view controller. You then "push" the next view controller on top of the current one. When done, you can "pop" that view controller to return to the previous one.

I suggest you read the " View Controller Programming Guide for iOS " for a good discussion about view controller, navigation controllers, tab bar controllers, and others. You'll be lost until you do.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM