【发布时间】:2012-01-08 07:49:08
【问题描述】:
这是我第一次在这里发帖,非常感谢您的帮助。我已经搜索了谷歌以及这个网站寻求帮助,但没有找到与我正在寻找的东西非常相似的东西。我正在尝试海拔高度
-(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";
}
例如,这给了我“500.00 英尺”之类的信息。我有另一个文本字段,我想根据altitudeField.text 中的高度值填写。如果海拔
原来的高度是以米为单位的,但我只是乘以它得到英尺,所以我必须以米为单位查看原始值吗?或者我可以查看altitudeField中的实际值吗?
我一直在尝试操纵我发现的一些标准 if-else 语句,但我得到的只是错误。任何帮助或方向将不胜感激。
【问题讨论】:
-
你的意思是像 if (altitude.text == @"10.00 ft") {} 吗?
-
-(IBAction)calculate { float a = ([textField6.text floatValue]);浮动 h = ([textField2.text floatValue]);浮动 d = ([textField3.text floatValue]);浮动 f = (3600/[stopWatchField.text floatValue])*d; float s = ([textField4.text floatValue]); float r = ([textField5.text floatValue]);浮动 e = ([textField1.text floatValue]);浮动 c = ((e*(h*f))/((s-r)*a)); label2.text = [[[NSString alloc] initWithFormat:@"%.2f", f] autorelease]; label.text = [[[NSString alloc] initWithFormat:@"%.2f", c] autorelease]; }
-
对不起,我不是故意要发布的,我按下回车键就发布了。但这就是我要发布的方程式。其中 [textField6.text floatValue] 将由 AltitudeField 决定。
-
@iBrad Apps:假设您尝试将字符串与“10.00 ft”进行比较,该功能不适用于您尝试执行的操作。在两个字符串上使用
==运算符将比较它们的指针值,并且只有当字符串是相同的字符串(在内存中,不一定在值中)时,它们才会传递该运算符并返回true。你会想要if([[altitude text] isEqualToString:@"10.00 ft"]) {}
标签: iphone ios core-location