TopViewControllerDetection 2.0.3

TopViewControllerDetection 2.0.3

Maintained by Siarhei Ladzeika.



  • By
  • Siarhei Ladzeika

TopViewControllerDetection

Build Status

Contains helper code (extension to UIApplication/UIViewController) to detect top visible view controller.

Installation

Cocoapods

This is the recommended way of installing this package.

  • Add the following line to your Podfile
pod 'TopViewControllerDetection'
  • Run the following command to fetch and build your dependencies
pod install

Manually

If you prefer to install this package manually, just follow these steps:

  • Make sure your project is a git repository. If it isn't, just run this command from your project root folder:
git init
  • Add TopViewControllerDetection as a git submodule by running the following command.
git submodules add https://github.com/ladeiko/TopViewControllerDetection.git
  • Add files ('.swift') from 'submodules/TopViewControllerDetection/Source' folder to your project.

Usage

Swift

See SwiftExample.swift

import TopViewControllerDetection

let absoluteTopViewController = UIApplication.shared.findTopViewController()

func viewDidLoad() {
	super.viewDidLoad()
	let topViewControllerRelativeToSelf = self.findTopViewController()
}


// Async version

self.findTopViewController { viewController in
    if let viewController =  viewController {
        // TODO
    }
}

Objective-C

See ObjCExample.m

@import TopViewControllerDetection;

UIViewController* const absoluteTopViewController = [[UIApplication sharedApplication] findTopViewController];

- (void)viewDidLoad {
	[super  viewDidLoad];
	UIViewController* const topViewControllerRelativeToSelf = [self findTopViewController];
}

Changelog

See CHANGELOG

LICENSE

This project is licensed under the MIT License - see the LICENSE file for details