locationSetupControllerWithCompletion:块方法返回' nil' ESTLocation对象?

时间:2015-03-17 13:05:47

标签: ios iphone ibeacon

我正在研究Estimote iBeacons,并尝试在Estimote SDK和室内位置SDK的帮助下创建演示应用程序。我正在使用室内位置SDK的演示应用程序,在此演示应用程序中,我在此代码中遇到问题:

UIViewController *nextVC = [ESTIndoorLocationManager locationSetupControllerWithCompletion:^(ESTLocation *location, NSError *error) {

        [weakSelf dismissViewControllerAnimated:YES completion:^{
            if (location)
            {
                [[NSUserDefaults standardUserDefaults] setObject:[location toDictionary] forKey:LAST_CREATED_LOCATION_KEY];

                ESTIndoorLocationViewController *navigationVC = [[ESTIndoorLocationViewController alloc] initWithLocation:location];

                [weakSelf.navigationController pushViewController:navigationVC animated:YES];
            }
        }];
    }];

    UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:nextVC];
    [self presentViewController:navController animated:YES completion:nil];

实际上我遇到的问题是我得到的location对象的值是nil。我无法解决那里的问题。因为没有location对象,我无法使用信标进行进一步的室内定位操作。

所以,请为我提出任何合适的解决方案。 感谢。

2 个答案:

答案 0 :(得分:0)

如果传递给完成块的location参数是nil,则很可能是位置设置出错了。您应该在error对象中包含详细的错误信息:

if (location) {
    // ...
} else {
    NSLog(@"error when setting up location: %@", error);
}

答案 1 :(得分:0)

最后,我已经解决了这个问题。 实际上我没有严格按照说明创建室内位置,所以这个方法返回零位置对象。 出现此问题是因为我没有将所有信标放在正确的位置。

相关问题