たくさんの画像を含む Web アプリを作成しました。Safari のメモリでは、それらのすべてを開くことはできません。そこで、画像を iPad に保存するアプリケーションを作成します。ただし、それらは動的に変更される可能性があり、ファイルをどこに保存できるかわかりません。コードの残りの部分は、いくつかの画像を配置したファイルで動作します。
注意:シミュレータ (iPad) では正常に動作しますが、実際のデバイスでは権限の問題があります。
これは私のコードです:
UIImage *image = [[UIImage alloc] initWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString: [NSString stringWithFormat:@"http://link_of_my_image", [splitLink objectAtIndex: 1],[splitLink objectAtIndex: 3] ] ]]];
NSData *data1 = [NSData dataWithData:UIImagePNGRepresentation(image)];
BOOL test10 = [data1 writeToFile:[NSString stringWithFormat: @"%@/%@/folder/%@",linkSlidesFile, [splitLink objectAtIndex: 1],[splitLink objectAtIndex: 3]] atomically:YES];
NSLog(@"creat Image --------------------- %@ %i",
[NSString stringWithFormat: @"%@/%@/folder/%@",[splitLink objectAtIndex: 0], [splitLink objectAtIndex: 1],[splitLink objectAtIndex: 3]], test10);
ログシミュレーター:
creat Image --------------------- Link_of_image_ipad 1
ログ iPad :
creat Image --------------------- Link_of_image_ipad 0
助けてくれませんか?