获取 ALAsset 的路径
如何获取 ALAsset 数组中每个项目的路径?
我想获取图像,以便将它们添加到电子邮件中,
例如
NSString *path = [[NSBundle mainBundle] pathForResource:@"sample" ofType:@"png"];
NSData *myData = [NSData dataWithContentsOfFile:path];
[mailViewController addAttachmentData:myData mimeType:@"image/png" fileName:@"sample"];
这怎么能做到呢?
How can I get the path of each item in an array of ALAssets?
I would like to get the images so that I can add them to an email
e.g.
NSString *path = [[NSBundle mainBundle] pathForResource:@"sample" ofType:@"png"];
NSData *myData = [NSData dataWithContentsOfFile:path];
[mailViewController addAttachmentData:myData mimeType:@"image/png" fileName:@"sample"];
How can this be done?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
假设您已经有权访问 ALAsset 对象数组,您可以像这样检索它们的 URL:
someAsset.defaultRepresentation.url
Assuming you already have access to an array of ALAsset objects, you can retrieve their URL like this:
someAsset.defaultRepresentation.url
假设您有资产 URL,例如 asset-library://asset/asset.JPG?id=1000000477&ext=JPG:
Assuming you have the Asset URL, such as assets-library://asset/asset.JPG?id=1000000477&ext=JPG:
如果您有 ALAsset 数组,则可以加载资产数据。
If you have an array of ALAssets then you can load the asset data.