¿Cómo funciona el botón Atrás del controlador de la barra de navegación en el Iphone?

When we click back button in navigation controller, it'll automatically pops the view controller and goes back to the previous view controller.. could anyone tell me how it's works.. where is the code for that action in xcode.

preguntado el 02 de febrero de 12 a las 11:02

3 Respuestas

The code which does all of that is handled in Apple's UINavigationController class. You don't get to see this code.

If you want to change the behavior of Apple's classes they sometimes delegate responsibility for some of the actions they perform, or sometimes just provide information that something is going to happen.

For example if your class becomes the delegate of UINavigationController it will send you two messages:

– navigationController:willShowViewController:animated:
– navigationController:didShowViewController:animated:

Respondido 02 Feb 12, 15:02

Thanks jack. But we can see the UINavigationController Class functions right..? - veeramani

Yup. The UINavigationController tells you what functions it can perform. In objective-c these are declared in a .h file while the code goes in a .m file. In Xcode go to file>Open Quickly and type in UINavigationController.h. Alternatively you can look in the documentation to see what it does. However you do not get to see that actual code. - jackslash

I dont know what you exactly mean by "how it works"..but what happens is the view controllers are placed in a stack (RootController which is the Navigation controller) and when you press "back" button it simply pops the top most controller in the stack and you are back from where you came.Hope it helps..!!

Respondido 02 Feb 12, 15:02

when we press back button it pops the viewcontroller. but there must be code for this action right..?. Where'll be that code exists..? - veeramani

Are you looking this?

 [self.navigationController popViewControllerAnimated:YES];

Respondido 02 Feb 12, 15:02

no simone.. when we press back button it pops the viewcontroller. but there must be code for this action right..?. Where'll be that code exists..? - veeramani

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.