Latest 2.0.0
Homepage https://github.com/ladeiko/TopViewControllerDetection
License MIT
Platforms ios 10.0, requires ARC
Authors

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

Latest podspec

{
    "name": "TopViewControllerDetection",
    "version": "2.0.0",
    "summary": "TopViewControllerDetection - helper code to detect current top visible UIViewController",
    "homepage": "https://github.com/ladeiko/TopViewControllerDetection",
    "license": "MIT",
    "authors": {
        "Siarhei Ladzeika": "[email protected]"
    },
    "source": {
        "git": "https://github.com/ladeiko/TopViewControllerDetection.git",
        "tag": "2.0.0"
    },
    "platforms": {
        "ios": "10.0"
    },
    "requires_arc": true,
    "swift_version": "4.2",
    "source_files": "Source/*.swift"
}

Pin It on Pinterest

Share This