ReplaceRootViewController
信息
此项目展示了针对 http://www.openradar.me/21404408 的修复方案。
该问题已在多个 Stackoverflow 支持页面上提出。这个 Pod 库旨在通过动画轻松更换根视图控制器。
您需要使用 xcode 中的控制台和调试工具(例如“调试视图层次结构”)来验证一切是否按预期工作。UI 测试也提供了。
归属
以下没有这些...
- API 设计基于... https://github.com/malcommac/UIWindowTransitions
- 由 Stackoverflow 响应提供的内存泄漏修复 https://stackoverflow.com/a/27153956/8923019
代码...
if let window = view.window {
window.set(rootViewController: yourReplacementViewController)
}
如果您想,还可以有一个回调:..
if let window = view.window {
window.set(rootViewController: yourReplacementViewController) { (completed) in
print("Root view replaced!")
}
}
示例
要运行示例项目,请先克隆仓库,然后从Example目录中运行pod install
。
安装
ReplaceRootViewController 通过 CocoaPods 提供。要安装它,只需将以下行添加到您的 Podfile 中
pod 'ReplaceRootViewController'
作者
sushant, [email protected]
许可协议
ReplaceRootViewController 在 MIT 许可协议下可用。有关更多信息,请参阅 LICENSE 文件。