使用AssetPath创建NSURL [英] Create NSURL using AssetPath
本文介绍了使用AssetPath创建NSURL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用UIImagePickerController,我可以获得像 assets-library://asset/asset.MOV?id = 2A2CE6C9-C178-4395-977B-E6F159BF6D5E& ext这样的媒体的资产路径= MOV
。
Using UIImagePickerController, I'm able to get the Asset Path for a Media like assets-library://asset/asset.MOV?id=2A2CE6C9-C178-4395-977B-E6F159BF6D5E&ext=MOV
.
NSURL *instagramURL = [NSURL URLWithString:[NSString stringWithFormat:@"instagram://library?AssetPath=%@&InstagramCaption=%@",[referenceURL absoluteString], strInstagramCaption]];
现在,我想将此资产路径转换为NSURL以将其传递到以下代码块:
Now, I want to convert this Asset Path into NSURL to pass it into following code block :
if ([[UIApplication sharedApplication] canOpenURL:instagramURL])
{
[[UIApplication sharedApplication] openURL:instagramURL];
}
推荐答案
这是如何将资产路径转换为有效 NSUrl
: -
This is the way how you should convert asset path to valid NSUrl
:-
NSURL *instagramURL = [NSURL URLWithString:[[NSString stringWithFormat:@"instagram://library?AssetPath=%@&InstagramCaption=%@",[assetURL absoluteString],caption]stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
if ([[UIApplication sharedApplication] canOpenURL:instagramURL]) {
[[UIApplication sharedApplication] openURL:instagramURL];
}
来自这个
这篇关于使用AssetPath创建NSURL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文