我想设置一些位置并让我的应用程序检查它是否通过这些位置中的任何一个,如果用户是,那么我希望UIPickerView
根据他们所在的位置自动选择我设置的值。
我对 iOS 的 Objective c 和编码非常熟悉,但我真的没有对核心位置做过任何事情。我读过一些东西,但我需要一些帮助。
我所拥有的是 plist 文件中位置的纬度和经度。我可以获取当前用户的位置并使用此代码获取坐标
int degrees = newLocation.coordinate.latitude;
double decimal = fabs(newLocation.coordinate.latitude - degrees);
int minutes = decimal * 60;
double seconds = decimal * 3600 - minutes * 60;
NSString *lat = [NSString stringWithFormat:@"%d° %d' %1.4f\"",
degrees, minutes, seconds];
degrees = newLocation.coordinate.longitude;
decimal = fabs(newLocation.coordinate.longitude - degrees);
minutes = decimal * 60;
seconds = decimal * 3600 - minutes * 60;
NSString *longt = [NSString stringWithFormat:@"%d° %d' %1.4f\"",
degrees, minutes, seconds];
我想做的是将用户当前位置与 plist 文件中的位置进行比较,如果它们与 plist 文件中的任何位置相距几英里,那么它将在 UIPickerView 中自动选择一个阀门。我已经知道如何从 UIPickerView 中选择一些东西。