- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
是否可以从 PHAsset 访问城市名称和州等位置信息。 iOS 照片应用程序显示非常具体的位置信息,例如美国华盛顿州西雅图的贝尔敦。但是,我能够从 PHAsset 访问的所有内容都是来自 location 属性的 CALocation。我相信这只会为我提供地理坐标,因此仍然需要反向地理编码。我有数千张照片可以对每个用户进行反向地理编码。因此,我想避免进行反向地理编码,而只是访问 Apple 已经在照片应用程序中显示的人类可读位置信息。
简而言之,给定一个 PHAsset 对象,我如何在不使用反向地理编码服务的情况下访问照片位置的城市名称?
最佳答案
在 PHAsset
中有一个位置属性,使用它。
static NSString *const kCityString = @"City";
@property (nonatomic, copy) NSString *cityString;
...
CLGeocoder *geocoder = [CLGeocoder new];
__weak typeof(self) weakSelf = self;
[geocoder reverseGeocodeLocation:location completionHandler:^(NSArray *placemarks, NSError *error) {
__strong typeof(weakSelf) strongSelf = weakSelf;
CLPlacemark *placemark = placemarks.lastObject;
// deprecated since iOS 11.0
strongSelf.cityString = placemark.addressDictionary[kCityString];
// or equivalent
strongSelf.cityString = placemark.locality;
}];
去看看 CLPlacemark
的其他属性。
关于ios - 如何从 iOS 8 照片框架中的 PHAsset 获取城市名称、省、州?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27444093/
我正在尝试获取相册中的所有照片 (PHAssets) 并将它们附加到一个数组中,以便我可以将其作为完成参数传递。 代码在包含 arrayOfPHAsset.append(asset) 的行崩溃。为什么
public func nohanaImagePicker(_ picker: NohanaImagePickerController, didFinishPickingPhotoKitAssets
我曾经使用 ALAssetLibrary。它有 assetForURL 功能,这样我就可以将 URL 保存到 NSUserDefaults 并在应用程序重新启动后通过 URL 检索 ALasset。
在 iOS 14 测试版中,有没有办法检查应用程序是否有权加载 PHAsset在尝试使用 PHImageManager.requestImage? 加载之前的图像这是给 PHAuthorization
我用过 `NSURL *urlA = [info valueForKey:@"PHImageFileURLKey"];` 但是当我尝试使用 URL 保存图像时,URL 为 nil。 `NSDat
我想添加 HDR 图标以指示某些 Assets 是 HDR,但如果这是来自 iphone12 的 HDR 视频记录,我无法获取任何信息来检查视频 最佳答案 + (BOOL)isHDRVideo:(
我有这个奇怪的错误,不知道如何修复它。 我的代码在 Xcode 7.3 中运行良好。但是,在更新到 Xcode 8 之后,我收到了将近 17 个错误和 21 个警告。这可能是 Swift 3 中的一些
在 iOS 的照片框架中,为了请求一组具有特定过滤器的 PHAssets,您可以使用 fetchAssetsWithOptions:options 并传递 >PHFetchOptions 对象与所
PHAsset creationDate返回一个NSDate,该NSDate的构造就像所有照片都是在同一“主”时区中拍摄的一样。例如,在给定的iPhone上,在纽约下午4点拍摄的照片与在加利福尼亚州下
我想知道如何复制 PHAsset并保留照片的上下文。例如,如果照片位于特定相册中,我希望副本位于同一个相册中,紧邻原始相册。如果可能,将保留编辑历史记录,允许用户在需要时将该副本恢复为原始版本。 可以
在 iOS8 上使用照片应用程序时,您可以在查看每张特定照片时看到位置标题。例如“Home”或“Central Park”——如何从 PHAsset 或类似类中获取数据/字符串? 我没有在 PHAss
在 Objective-C 中,我想在后台将所有 PHAssets(图像和视频)上传到我的服务器。任何人都可以建议我该怎么做吗? 最佳答案 let mPhasset : PHAsset = PHAss
我正在使用名为 BSImagePicker 的第三方库从照片库中选择多张图像。我可以设置要选择的最大 PHAssets,但是当我显示 BSImagePickerController 以选择更多照片时,
是否可以将新的 PHAsset 插入相机胶卷中的指定索引? 我试过以下: let cam_req = PHAssetCollectionChangeRequest(for: camera_roll)
保存图像后如何获取图像的 PHAsset,以便将 Assets 的本地标识符保存到我的存储解决方案中并在以后使用图像? 最佳答案 我从来没有这样做过,但我想有一个 PhotoKit 方法允许检索最近保
我看到对于 PHContentEditingInput ( https://developer.apple.com/library/prerelease/ios/documentation/Photo
我正在使用 UIImagePickerController 来允许用户使用相机拍照。当代表被调用时,我想将图像保存到照片库/相机胶卷,我使用 PHAssetChangeRequest 来完成。问题是文
请问有没有办法用PHAsset获取原始文件名? 我使用以下代码提取文件信息。 [[PHImageManager defaultManager] requestImageDataForAsset:
我正在使用 UIImageWriteToSavedPhotosAlbum 将图像保存到照片应用程序。这是我发现的唯一可以让您执行此操作的功能。 这是我的代码: import UIKit import
我想对用户的照片库做一些工作。由于图书馆可能很大,我想在后台进行。我想知道执行 Assets 获取(如 PHAsset.fetchAssets )并在后台处理它们是否安全? 我现在只需要 Assets
我是一名优秀的程序员,十分优秀!