从URL Phonegap Iphone保存图像
我在谷歌上搜索了很多,但找不到解决办法 我需要一些方法来保存我的应用程序从网上的图片。就像一个函数,我可以将url放入其中,然后它将下载它: i、 e 有这样的东西吗?布拉格马克- pragma标记用于加载图像的线程从URL Phonegap Iphone保存图像,iphone,cordova,Iphone,Cordova,我在谷歌上搜索了很多,但找不到解决办法 我需要一些方法来保存我的应用程序从网上的图片。就像一个函数,我可以将url放入其中,然后它将下载它: i、 e 有这样的东西吗?布拉格马克- pragma标记用于加载图像的线程 这应该能奏效 - (void)downloadPhoto:(NSString*)urlToDownloadFrom { // Download the image. now downloadeImg has the img you want. UIImage *do
这应该能奏效
- (void)downloadPhoto:(NSString*)urlToDownloadFrom
{
// Download the image. now downloadeImg has the img you want.
UIImage *downloadedImg = [UIImage imageWithData: [NSData dataWithContentsOfURL:
[NSURL URLWithString: urlToDownloadFrom]]];
UIImageWriteToSavedPhotosAlbum(downloadedImg,self,
@selector(savedPhotoImage:didFinishSavingWithError:contextInfo:),NULL);
// saves the image into your Photos.app/directory and calls the savedPhotoImage fucn. Am unclear if you actually needed this function.
}
-(void)savedPhotoImage:(UIImage *)imagedidFinishSavingWithError:(NSError *)errorcontextInfo:(void *)contextInfo
{
}
谢谢但是,我用的是phonegap。。。所以我不知道如何实现这一点。我不会说目标C…你从url下载图片成功了吗?
- (void)downloadPhoto:(NSString*)urlToDownloadFrom
{
// Download the image. now downloadeImg has the img you want.
UIImage *downloadedImg = [UIImage imageWithData: [NSData dataWithContentsOfURL:
[NSURL URLWithString: urlToDownloadFrom]]];
UIImageWriteToSavedPhotosAlbum(downloadedImg,self,
@selector(savedPhotoImage:didFinishSavingWithError:contextInfo:),NULL);
// saves the image into your Photos.app/directory and calls the savedPhotoImage fucn. Am unclear if you actually needed this function.
-(void)savedPhotoImage:(UIImage *)imagedidFinishSavingWithError:(NSError *)errorcontextInfo:(void *)contextInfo
{
}