【发布时间】:2021-03-22 05:10:58
【问题描述】:
我正在使用 UIImagePickerController 从照片库中选择一个视频。我已经得到了视频的创建时间和日期,我想知道它的拍摄地点。我知道在 iphone 上拍摄的视频将位置作为其元数据的一部分,但我不知道如何访问它。
这是我用于日期和时间的代码。
else if (picker.sourceType ==UIImagePickerControllerSourceTypePhotoLibrary) {
NSURL * movieURL = [info valueForKey:UIImagePickerControllerMediaURL] ;
AVURLAsset *anAsset = [[AVURLAsset alloc] initWithURL:movieURL options:nil];
PHAsset *theAsset = [info valueForKey:UIImagePickerControllerMediaURL] ;
PHAsset *someAsset = [info valueForKey:UIImagePickerControllerPHAsset];
NSLog(@"someAsset%@",someAsset.location);
self.currentLocation = someAsset.location;
NSLog(@"creationDate1:%@",theAsset);
NSLog(@"creationDate2:%@",anAsset.creationDate.value);
NSDate *creationDate =(NSDate *)anAsset.creationDate.value;
NSDateFormatter *dateFormatter=[[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"MMMM-dd-yyyy"];
dayString = [dateFormatter stringFromDate:creationDate];
NSDateFormatter *dateFormatter2=[[NSDateFormatter alloc] init];
[dateFormatter2 setDateFormat:@"hh:mm a"];
timeString = [dateFormatter2 stringFromDate:creationDate];
我试图找到位置密钥,但没有成功。
有人可以告诉我如何做到这一点或指出一个好的教程以及如何完成这个。我正在使用objective-c。
感谢所有帮助。
【问题讨论】:
标签: ios location uiimagepickercontroller phasset