Let's think a little more carefully
about how the NavigationController is
keeping track of ViewControllers.
A navigation controller has
a stack of ViewControllers.
Remember that a stack is
a Last-In-First-Out data structure,
like a stack of cups.
It has two operations.
Items are popped off of the stack,
and items are pushed onto the stack.
When we start the Settings app,
the top level settings page is
displayed with the title, Settings.
If we click on Notifications,
a new ViewController gets
pushed onto the stack.
We can choose to push a number
of different views next.
Phone, Messages, Passbook.
Now the stack is three
ViewControllers deep.
We only have one choice
if we want to pop.
That corresponds to the Back button.
You can see here beside the Back button
that the navigation bar shows the title
of the next ViewController on the stack.
In this case,
it's the Settings ViewController.
دعونا نفكر بعناية أكثر
في طريقة متابعة NavigationController
.لـ ViewControllers
تحتوي وحدة التحكم في التنقل
.على مكدس ViewControllers
تذكروا أن المكدس هو
،مصدر بيانات Last-In-First-Out
.مثل مكدس كؤوس
.ويحتوي على عمليتين
،يتم انبثاق العناصر خارج المكدس
.ويتم دفع العناصر إلى المكدس
،وعند بدء تشغيل تطبيق Settings
يتم عرض صفحة الإعدادات
.من خلال جزء Settings الصغير
،وفي حالة النقر فوق Notifications
يتم دفع وحدة ViewController جديدة
.إلى المكدس
ويمكن أن نختار دفع عدد
.من العروض المختلفة بعد ذلك
.وهي Phone، وMessages، وPassbook
والآن أصبح المكدس بعمق ثلاث وحدات
.ViewControllers
لدينا خيار واحد فقط
.إذا كنا نريد الانبثاق
.وهذا مطابق لعمل زر Back
يمكنكم أن تشاهدوا هنا بجوار زر Back
أن شريط التنقل يعرض بعض
.وحدة ViewController التالية على المكدس
،وفي هذه الحالة
.تكون Settings ViewController
Vamos pensar com um pouco mais de atenção
como o NavigationController está
mantendo o controle de ViewControllers.
Um controlador de navegação tem
uma pilha de ViewControllers.
Lembre-se que uma pilha é
uma estrutura de dados "Último a entrar, Primeiro a sair",
como uma pilha de copos.
Ela tem duas operações.
Itens são retirados da pilha
e itens são empurrados para a fila.
Quando iniciamos o aplicativo Settings,
a página de configurações de nível superior é
exibida com o título, Settings.
Se clicarmos em Notifications,
um novo ViewController é
empurrado para a pilha.
Podemos escolher para empurrar um número
de diferentes exibições a seguir.
Telefone, Mensagens, Caderneta.
Agora a pilha está três vezes mais profunda no
ViewControllers.
Nós só temos uma escolha
, se queremos sair.
Isso corresponde ao botão Back.
Você pode ver aqui ao lado do botão Back
que a barra de navegação mostra o título
do próximo ViewController na pilha.
Nesse caso,
é o Settings ViewController.