位置管理器无法运行 iPhone 应用程序
[locationManager StarUpdatingLocation]
在我的情况下不起作用。我有一个 NSOBject 类,其中有一个这样的方法。
(void)findlocation
{
locationManager = [[CLLocationManager alloc] init] ;
locationManager.delegate = self;
locationManager.distanceFilter = kCLDistanceFilterNone;
locationManager.desiredAccuracy = kCLLocationAccuracyHundredMeters;
[locationManager startUpdatingLocation];
}
然后我有委托方法
(void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
但是使用 NSLog 语句我认为启动约会位置方法不会进入此位置管理器方法。 :( 我在同一个类的另一个方法中调用当前位置方法,所以我会说 [self currentLocation]。任何帮助将不胜感激。谢谢。
[locationManager StarUpdatingLocation]
doesnt work in my case. I have an NSOBject class in which i have a method like this.
(void)findlocation
{
locationManager = [[CLLocationManager alloc] init] ;
locationManager.delegate = self;
locationManager.distanceFilter = kCLDistanceFilterNone;
locationManager.desiredAccuracy = kCLLocationAccuracyHundredMeters;
[locationManager startUpdatingLocation];
}
Then I have the delegate methods
(void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
However using an NSLog statement i figured that the startupdating location method doesnt go into this locationmanager method. :( I am calling the current location method in another method in the same class so i would be saying [self currentLocation]. Any help would be appreciated. thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
符合您拥有此代码的类中的协议
CLLocationManagerDelegate
。如果是这种情况,那么您应该看看这段代码在设备中是否正常工作。我认为你正在模拟器中运行它
CLLocationManagerDelegate
没有被触发对代码感到不安。如果您使用模拟器,则默认情况下模拟器的位置设置为“无”。
请检查。
如果这有效,那么您也可以进入模拟器。
希望有帮助。
Conform to protocol
CLLocationManagerDelegate
in your Class where you have this code.If this is the case, then you should see whether or not this code is working fine in Device. I think you are running this in simulator & the
CLLocationManagerDelegate
is not fired & getting upset on code.If you are using simulator then by default the location of Simulator is set to None.
Kindly check.
If this works then you are good to go in simulator as well.
hope that helps.