0

このコード行を使用しようとしています

 [UIImagePNGRepresentation(image, 1.0) writeToFile:pngPath atomically:YES];

しかし、明らかに pngPath は宣言されていません。だから私は使用する必要がありますstringByAppendingPathComponent

私はこれの例をグーグルで検索しました、そして私はこれを見つけました

myPlistPath = [documentsDirectory stringByAppendingPathComponent: 
 [NSString stringWithFormat: @"%@.plist", plistName] ];
[myPlistPath retain]

;

問題は、必要がないため、plist ファイルがないことです。これらすべての問題を解決し、UIImage 画像を writeToFile にするにはどうすればよいですか?

4

1 に答える 1

1

あなたの質問を完全には理解していませんが、ファイルを保存するフルパスを取得するには、これを試すことができます:

NSString *file = @"myfile.png";
NSString *directory = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES) objectAtIndex:0];
NSString *path = [directory stringByAppendingPathComponent: file];

その後:

[UIImagePNGRepresentation(image) writeToFile:path atomically:YES];
于 2010-11-04T14:37:16.773 に答える