0
問題我想使用此行代碼與UIImagePNGRepresentation
[UIImagePNGRepresentation(image, 1.0) writeToFile:pngPath atomically:YES];
但顯然pngPath是未申報。所以我必須使用stringByAppendingPathComponent
。
我GOOGLE的這個實施例中,我發現這個
myPlistPath = [documentsDirectory stringByAppendingPathComponent:
[NSString stringWithFormat: @"%@.plist", plistName] ];
[myPlistPath retain]
;
問題是我沒有plist文件,因爲我不需要一個。我該如何解決所有這些問題,然後writeToFile UIImage圖像?
謝謝!這正是我的問題。唯一的是我得到1錯誤:太多的參數功能'UIImagePNGRepresentation'。這是我的代碼,這就是你給我的。 – Joethemonkey101 2010-11-04 14:52:28
NSString * file = @「GameOver Screenshot」; \t NSString * directory = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES)objectAtIndex:0]; \t NSString * path = [directory stringByAppendingPathComponent:file]; \t [UIImagePNGRepresentation(image,1.0)writeToFile:path at atomically:YES]; \t return image; – Joethemonkey101 2010-11-04 14:52:56
對,對不起;我copy'n粘貼在你的問題的代碼。它應該是'UIImagePNGRepresentation(image)'。第二個參數僅用於'UIImageJPEGRepresentation'(它是質量參數)。如果它有幫助,請考慮upvoting /接受答案。謝謝。 – pt2ph8 2010-11-04 14:57:46