Skip to content

working with SWRevealViewController #3

Description

@mahdigh99

add this :

else if (rootViewController is SWRevealViewController) {
            return topViewControllerWithRootViewController((rootViewController as! SWRevealViewController).frontViewController)
        }

in to topViewControllerWithRootViewController.
will work correctly with SWRevealViewController.

final code:

 private func topViewControllerWithRootViewController(_ rootViewController: UIViewController!) -> UIViewController? {
        if (rootViewController == nil) { return nil }
        if (rootViewController is UITabBarController) {
            return topViewControllerWithRootViewController((rootViewController as! UITabBarController).selectedViewController)
        } else if (rootViewController is UINavigationController) {
            return topViewControllerWithRootViewController((rootViewController as! UINavigationController).visibleViewController)
        } else if (rootViewController.presentedViewController != nil) {
            return topViewControllerWithRootViewController(rootViewController.presentedViewController)
        }else if (rootViewController is SWRevealViewController) {
            return topViewControllerWithRootViewController((rootViewController as! SWRevealViewController).frontViewController)
        }
        return rootViewController
    }

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions