TopViewControllerDetection 2.0.3

TopViewControllerDetection 2.0.3

Siarhei Ladzeika 维护。



  • Siarhei Ladzeika

TopViewControllerDetection

Build Status

包含用于检测顶层可见视图控制器的辅助代码(对 UIApplication/UIViewController 的扩展)。

安装

Cocoapods

这是安装此包的推荐方式。

  • 将以下行添加到您的 Podfile 中
pod 'TopViewControllerDetection'
  • 运行以下命令以获取并构建您的依赖项
pod install

手动

如果您喜欢手动安装此包,请按照以下步骤操作

  • 确保您的项目是 git 仓库。如果不是,请从您的项目根文件夹运行以下命令
git init
  • 通过运行以下命令将 TopViewControllerDetection 添加为 git 子模块。
git submodules add https://github.com/ladeiko/TopViewControllerDetection.git
  • 'submodules/TopViewControllerDetection/Source' 文件夹中的文件(' swift')添加到您的项目中。

使用说明

Swift

参见 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

参见 ObjCExample.m

@import TopViewControllerDetection;

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

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

变更日志

参见 CHANGELOG

许可证

本项目受MIT许可证许可 - 有关详细资料,请参阅LICENSE文件