Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ios using global navigation controller

Tags:

ios

I'm trying to push something to my "current" navigation controller, but it's not going.

Why doesn't [[[[[[UIApplication sharedApplication] delegate] window] rootViewController] navigationController] presentModalViewController:myView animated:YES]; work?

like image 947
Jacksonkr Avatar asked Dec 30 '25 20:12

Jacksonkr


1 Answers

[[window rootViewController] navigationController] refers to the navigation controller that contains the rootViewController. Since the root controller is not inside any navigation controller, it will be always nil.

The rootViewController is probably the navigation controller itself. If that is the case you can use the code below:

[[[[[UIApplication sharedApplication] delegate] window] rootViewController] presentModalViewController:myViewController animated:YES]

By the way, you cannot present a view modally, you should present its controller.

like image 83
murat Avatar answered Jan 01 '26 09:01

murat



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!