Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/clojure/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从URL Phonegap Iphone保存图像_Iphone_Cordova - Fatal编程技术网

从URL Phonegap Iphone保存图像

从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

我在谷歌上搜索了很多,但找不到解决办法

我需要一些方法来保存我的应用程序从网上的图片。就像一个函数,我可以将url放入其中,然后它将下载它:

i、 e

有这样的东西吗?

布拉格马克- pragma标记用于加载图像的线程
这应该能奏效

- (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
{
}