gpt4 book ai didi

ios - 如何让导航 Controller 在屏幕外加载时加载其 Root View Controller ?

转载 作者:塔克拉玛干 更新时间:2023-11-01 19:09:35 25 4
gpt4 key购买 nike

我使用 ECSlidingViewController在我的应用程序中获得侧抽屉效果。当我的初始 View 加载时,有一个带有 MKMapView 的隐藏 View Controller 。在可见的 View 后面。需要从 map 注释中分离出来,我不得不将我的 map View Controller 嵌入到导航 Controller 中。现在隐藏的 View Controller 是一个导航 Controller 而不是 map View ,所以我的 map 只有在导航 Controller 出现在屏幕上后才会初始化。所以我的 map 的 viewDidLoad,它设置了区域,在 map View 的 CLLocationManager 之前被调用。代表有时间回复一个位置。

我需要让我的导航 Controller 和 Root View Controller 同步实例化。我只是手动 segue,但我猜 'rootViewController' 关系 segue 有我会绕过的实现细节。

最佳答案

这实际上很简单,与 segues 无关。

我期望 UINavigationController 对象上有一个 rootViewController 属性,而忽略了 @property UIViewController* topViewController

所以在我的顶部(可见)导航 Controller 的 viewWillAppear 中:

// Load the map's navigation controller from storyboard
MyMapNavigationController* mapNavigation = [self.storyboard instantiateViewControllerWithIdentifier:mapNavigtionIdentifier];

// ECSlidingViewController API to set hidden view controllers
self.slidingViewController.underRightViewController = mapNavigation;

// Grab root view controller
MyMapController* map = mapNavigation.topViewController;

// Slightly hacky magic
[map view]; //lazily instantiated property will initialize view and controller when called.

关于ios - 如何让导航 Controller 在屏幕外加载时加载其 Root View Controller ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18649802/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com