You can access it with:
MyViewController* mainController = (MyViewController*) self.window.rootViewController;
If you are nesting your view behind a tabviewcontroller or navigation controller it will return that to you and you will need to access your view controller inside of it
More Related Contents:
- How to find topmost view controller on iOS
- How to change Navigation Bar color in iOS 7?
- Detecting sheet was dismissed on iOS 13
- viewWillDisappear: Determine whether view controller is being popped or is showing a sub-view controller
- Programmatically change rootViewController of storyBoard
- How do I give an “identifier” to a view controller within my storyboard?
- Prevent segue in prepareForSegue method?
- Switching ViewControllers with UISegmentedControl in iOS5
- Can’t Load UIViewController XIB file in Storyboard in Swift
- viewDidLoad is called twice
- How do I size a UITextView to its content?
- Move view with keyboard using Swift
- iOS – Dismiss keyboard when touching outside of UITextField
- Is it possible to Turn page programmatically in UIPageViewController?
- Outlets cannot be connected to repeating content iOS
- UIViewController returns invalid frame?
- How to ignore touch events and pass them to another subview’s UIControl objects?
- Storyboard doesn’t contain a view controller with identifier
- Table Header Views in StoryBoards
- Popover with embedded navigation controller doesn’t respect size on back nav
- How to trap on UIViewAlertForUnsatisfiableConstraints?
- Present modal view controller in half size parent controller
- Achieving bright, vivid colors for an iOS 7 translucent UINavigationBar
- Example for login screen modally based on storyboard
- Autolayout: Add constraint to superview and not Top Layout Guide?
- Designing inside a scrollview in xcode 4.2 with storyboards
- Why can’t I call the default super.init() on UIViewController in Swift?
- iOS 11 large-title navigation bar not collapsing
- Swift: Navigate to new ViewController using button
- difference between presentViewController and UINavigationController?