Ios 捕获照片的GPS位置,并存储图像
我正在创建一个应用程序,允许用户拍摄照片或从照片卷中选择一张照片,并通过电子邮件发送到特定地址。但是,如果一个人拍了一张照片,然后在发送电子邮件之前移动,那么下面的代码是有效的,GPS位置是不准确的 我有没有办法:Ios 捕获照片的GPS位置,并存储图像,ios,gps,uiimagepickercontroller,Ios,Gps,Uiimagepickercontroller,我正在创建一个应用程序,允许用户拍摄照片或从照片卷中选择一张照片,并通过电子邮件发送到特定地址。但是,如果一个人拍了一张照片,然后在发送电子邮件之前移动,那么下面的代码是有效的,GPS位置是不准确的 我有没有办法: 拍摄照片,将照片拍摄位置的纵横比存储到 从照片盘中选择一张照片,提取横向和纵向,并存储到变量 这是我的密码: - (IBAction)takePhoto { picker1 = [[UIImagePickerController alloc] init]; pic
- 拍摄照片,将照片拍摄位置的纵横比存储到
- 从照片盘中选择一张照片,提取横向和纵向,并存储到变量
- (IBAction)takePhoto
{
picker1 = [[UIImagePickerController alloc] init];
picker1.delegate = self;
[picker1 setSourceType: UIImagePickerControllerSourceTypeCamera];
[self presentViewController:picker1 animated:YES completion:NULL];
locationManager.delegate = self;
locationManager.desiredAccuracy = kCLLocationAccuracyBest;
[locationManager startUpdatingLocation];
}
- (IBAction)chooseExisting
{
picker2 = [[UIImagePickerController alloc] init];
picker2.delegate = self;
[picker2 setSourceType: UIImagePickerControllerSourceTypePhotoLibrary];
[self presentViewController:picker2 animated:YES completion:NULL];
locationManager.delegate = self;
locationManager.desiredAccuracy = kCLLocationAccuracyBest;
[locationManager startUpdatingLocation];
}
#pragma mark - CLLocationManagerDelegate
- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error
{
NSLog(@"didFailWithError: %@", error);
UIAlertView *errorAlert = [[UIAlertView alloc]
initWithTitle:@"Error" message:@"Failed to Get Your Location" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[errorAlert show];
}
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
{
NSLog(@"didUpdateToLocation: %@", newLocation);
CLLocation *currentLocation = newLocation;
if (currentLocation != nil) {
longditute = [NSString stringWithFormat:@"%.8f", currentLocation.coordinate.longitude];
Latitude = [NSString stringWithFormat:@"%.8f", currentLocation.coordinate.latitude];
}
// Stop Location Manager
[locationManager stopUpdatingLocation];
}
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
image = [info objectForKey:UIImagePickerControllerOriginalImage];
[imageView setImage:image];
[self dismissViewControllerAnimated:YES completion:NULL];
}
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
{
[self dismissViewControllerAnimated:YES completion:NULL];
}
请参阅@maddy-我已尝试实现此解决方案,但由于某些原因,在我实现它们时,它们无法正常工作。