哪种数据类型将按原样返回值 (37.961498)?
我在 MapView 工作。目前我正在设置注释,因此我必须使用从 googleAPI 解析的一些 lat 和 lng (例如:lat = "37.9615000" 和 lng = "60.5566000") 设置 CLLocationCooperative2DMake 。我有字符串中的值,因此我将字符串转换为双精度,然后分配但它没有帮助。请有人帮助我。
double int1=[num1s floatValue];
double int2=[num2s floatValue];
NSLog(@" %f %f ",int1,int2);
annotation.coordinate=CLLocationCoordinate2DMake(int1, int2);
实际值为:37.9615000,60.5566000
我在 NSLog 中得到的值:37.961498、60.556599
提前致谢。
更多解释和我需要确切值的原因:
我需要为中国设置注释及其纬度和局域网 ( lat = "53.5609740";
长=“134.7728099”)
但是,当再次从字符串转换时,值会发生变化
当转换一个string
to a double
你应该使用doubleValue
代替floatValue
double int1=[num1s doubleValue];
double int2=[num2s doubleValue];
NSLog(@" %f %f ",int1,int2);
annotation.coordinate=CLLocationCoordinate2DMake(int1, int2);
也并不重要,但我不建议将双打命名为 int1 和 int2 ,这可能会在某些时候引起您的困惑
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)