user4951
user4951

Reputation: 33050

Why doesn't UINavigationController have a rootViewController property?

I am very curious. We really can't access it easily. I mean, I know it has, but not accessible.

Why?

Basically I want that rootViewController to be loaded before sending some events by accessing it's view. There is an postnotification that's set up on viewDidload.

Upvotes: 12

Views: 12473

Answers (1)

rmaddy
rmaddy

Reputation: 318774

If you have more than one, then use:

UIViewController *root = navController.viewControllers[0];

where navController is you UINavigationController. This will work always.

Use UINavigationController topViewController. This works if there is only one controller.

Upvotes: 18

Related Questions