iPhone 3.0指南针:如何获得标题? [英] iPhone 3.0 Compass: how to get a heading?
问题描述
我对Objective-C比较陌生,对它真的不太了解,所以我为这可能是一个非常业余的问题道歉。
I'm relatively new to Objective-C and really don't know much about it yet, so I apologise for what is probably a really amateurish question.
我正在尝试从CLHeading和CLLocationDirection获取磁路。但是我得到这行代码的编译错误:
I'm trying to get the magnetic heading from CLHeading and CLLocationDirection. However I'm getting compile errors for this line of code:
locationLabel.text = [[[location course] magneticHeading] stringValue];
错误包括:
warning: invalid receiver type 'CLLocationDirection'
error: cannot convert to a pointer type
我真的不明白我在这里做错了什么。请帮助!
I don't really understand what I'm doing wrong here. Please help!
推荐答案
以下是使用指南针所需的步骤。
Here are the steps needed to use the compass.
1)检查可用性:如果位置管理器的 headingAvailable
属性为YES,则可以使用指南针。
1) check the availability: if the headingAvailable
property of the location manager is YES, then you can use the compass.
2)使用位置管理器方法 - (void)startUpdatingHeading
开始接收您要搜索的信息
2) use the location manager method -(void) startUpdatingHeading
to begin receiving the information you are searching for
3)实际使用委托方法检索此信息(不要忘记将自己设置为委托)
3) actually retrieve this information using the delegate method (do not forget to set yourself as the delegate)
- (void)locationManager:(CLLocationManager *)manager didUpdateHeading:(CLHeading *)newHeading
希望这会有所帮助。
这篇关于iPhone 3.0指南针:如何获得标题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!