等待直到在 didFinishLaunchingWithOptions 中设置当前位置

发布于 2024-10-13 09:55:21 字数 766 浏览 2 评论 0原文

我的 Home UIView 需要当前位置坐标,并且在获得这些坐标之前我不希望调用它。我怎样才能最好地实现这一目标?

在此代码中,在更新当前位置之前调用视图:

 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

        currentLocation = [[CLLocation alloc] init];
    locationManager = [[CLLocationManager alloc] init];
    locationManager.delegate = self;
    [locationManager startUpdatingLocation];

TTNavigator *navigator = [TTNavigator navigator];
            navigator.persistenceMode = TTNavigatorPersistenceModeAll;
            TTURLMap *map = navigator.URLMap;

            [map from:@"tt://HomeView" toViewController:  viewController];
            [navigator openURLAction:[TTURLAction actionWithURLPath:@"tt://HomeView"]];
        }

My Home UIView requires current Location coordinates and I wouldn't want it to be called until I have these coordinates. How best can I achieve this?

in this code, the view is called before the update of current location:

 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

        currentLocation = [[CLLocation alloc] init];
    locationManager = [[CLLocationManager alloc] init];
    locationManager.delegate = self;
    [locationManager startUpdatingLocation];

TTNavigator *navigator = [TTNavigator navigator];
            navigator.persistenceMode = TTNavigatorPersistenceModeAll;
            TTURLMap *map = navigator.URLMap;

            [map from:@"tt://HomeView" toViewController:  viewController];
            [navigator openURLAction:[TTURLAction actionWithURLPath:@"tt://HomeView"]];
        }

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

海螺姑娘 2024-10-20 09:55:21

用户可以关闭位置服务。所以我不会那样做..
而是检查 didFinishLaunchingWithOptions 之后的位置,这样您当前的问题就会得到解决。
并添加一个屏幕,供用户在定位服务关闭时打开它。

users can have Location service turned off. so I wouldn't do that..
Instead check for the location after the didFinishLaunchingWithOptions, so that your current problem will be solved.
and add one more screen for user to turn on the location service if it's off.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文