I know that to get the current view controller from the app delegate, I can use the navigationController
property I have set up for my app. However, it's possible in many places throughout my app that a modal navigation controller could have been presented. Is there any way to detect this from the app delegate, since the current navigation controller will be different from the one to which the app delegate holds a reference?
相关问题
- CALayer - backgroundColor flipped?
- Core Data lightweight migration crashes after App
- How can I implement password recovery in an iPhone
- State preservation and restoration strategies with
- “Zero out” sensitive String data in Swift
相关文章
- 现在使用swift开发ios应用好还是swift?
- UITableView dragging distance with UIRefreshContro
- TCC __TCCAccessRequest_block_invoke
- Where does a host app handle NSExtensionContext#co
- xcode 4 garbage collection removed?
- Unable to process app at this time due to a genera
- Swift - hide pickerView after value selected
- How can I add media attachments to my push notific
This worked for me. I have many targets that have different controllers so previous answers didn't seemed to work.
first you want this inside your AppDelegate class:
then, in your function
In swift you can get the active ViewController like this :
If you have the navigation controller in the App Delegate, just use the visibleViewController property. It will give you the visible controller, even if it's a modal.
The best solution, works also with
moreNavigationController
inUITabBarController
: