This is my first time posting here so I would greatly appreciate the help. I have searched Google as well as this site for help and have not found anything quite like what I am looking for. I am trying to take the altitude
这是我第一次在这里发帖,所以我非常感谢你的帮助。我搜索谷歌以及这个网站寻求帮助,但没有找到任何与我正在寻找的东西相似的东西。我试图采取高度
-(void)locationManager:(CLLocationManager *)manager
didUpdateToLocation:(CLLocation *)newLocation
fromLocation:(CLLocation *)oldLocation
{
altitudeField.text = [NSString stringWithFormat: @"%.2f ft", newLocation.altitude * 3.2808399];
}
-(void)locationManager:(CLLocationManager *)manager
didFailWithError:(NSError *)error
{
altitudeField.text = @"0.00 ft";
}
Which gives me something like "500.00 ft" for instance. I have another textfield that I would like to fill in based on the altitude value in altitudeField.text. Where if the altitude is <1000 ft it equals 1.08 in textField6, from 1000 to 2000 ft it equals 1.04 in textField6, and so on in 1000 ft increments...
这给了我一些像“500.00英尺”的东西。我有另一个文本域,我想根据altitudeField.text中的高度值填写。如果海拔<1000英尺,它在textField6中等于1.08,从1000到2000英尺,在textField6中等于1.04,依此类推,以1000英尺为增量......
The original altitude is in meters, but I just multiply it to get it into feet, so must I look at the original value in meters? Or can I look at the actual value in the altitudeField?
原始高度以米为单位,但我只是乘以它将其变为英尺,所以我必须以米为单位查看原始值吗?或者我可以查看altitudeField中的实际值吗?
I have been trying to manipulate some standard if-else statements I have found but I get nothing but errors. Any help or direction would be greatly appreciated.
我一直试图操纵我发现的一些标准if-else语句,但我得到的只是错误。任何帮助或方向将不胜感激。
2 个解决方案
#1
1
Why not just do this:
为什么不这样做:
-(void)locationManager:(CLLocationManager *)manager
didUpdateToLocation:(CLLocation *)newLocation
fromLocation:(CLLocation *)oldLocation
{
double altitudeFt = newLocation.altitude * 3.2808399;
altitudeField.text = [NSString stringWithFormat: @"%.2f ft", altitudeFt];
double otherValue = 1.08 - 0.4 * floor(altitudeFt / 1000);
otherField.text = [NSString stringWithFormat:@"%.2f", otherValue];
}
#2
0
It sounds like you need to create a variable to store the numeric value of your altitude. You can then make what ever adjustments/conversions/formatting necessary when you set a particular field's text.
听起来你需要创建一个变量来存储海拔高度的数值。然后,您可以在设置特定字段的文本时进行必要的调整/转换/格式化。
#1
1
Why not just do this:
为什么不这样做:
-(void)locationManager:(CLLocationManager *)manager
didUpdateToLocation:(CLLocation *)newLocation
fromLocation:(CLLocation *)oldLocation
{
double altitudeFt = newLocation.altitude * 3.2808399;
altitudeField.text = [NSString stringWithFormat: @"%.2f ft", altitudeFt];
double otherValue = 1.08 - 0.4 * floor(altitudeFt / 1000);
otherField.text = [NSString stringWithFormat:@"%.2f", otherValue];
}
#2
0
It sounds like you need to create a variable to store the numeric value of your altitude. You can then make what ever adjustments/conversions/formatting necessary when you set a particular field's text.
听起来你需要创建一个变量来存储海拔高度的数值。然后,您可以在设置特定字段的文本时进行必要的调整/转换/格式化。