Voloda2
Voloda2

Reputation: 12607

How can I get any controller in UINavigationController?

How can I get any controller in UINavigationController? I can easily get top controller using the property topViewController; How can i get for example top -1 ?

Upvotes: 1

Views: 4700

Answers (2)

SPatil
SPatil

Reputation: 1003

There is a property of UINavigationController namely "viewControllers" which will work as follows:

NSArray *controllers = [navController viewControllers];

And now you can access any view controller from the returned array!

Upvotes: 7

Prakash Donga
Prakash Donga

Reputation: 558

By accessing the viewControllers property of UINavigationController you will get an array of pushed viewControllers So now you can access any viewController by indexing array.

Upvotes: 1

Related Questions