开发者

screenshots programmatically in IPad with the image name

how to save the screenshot programmatically in Ipad with image name taken from the user?

i've found a snippet which works but doesn't asks for the name of the image开发者_开发问答.

UIGraphicsBeginImageContext(self.view.frame.size);
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIImageWriteToSavedPhotosAlbum(viewImage, nil, nil, nil);

Also is it possible to create multiple folders in photo albums and save the image in it programmatically??


You cannot specify a name when you save the image to the photo album. If you want to do that, you have to save the image to the app's directory folder and then build a way to show to the user, the images he has saved internally and allow him to delete, load, etc.

This is how to save a PNG image to disk

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *appFile = [documentsDirectory stringByAppendingPathComponent:myFileName];
NSData *imageData = UIImagePNGRepresentation(myImage);

[imageData writeToFile:appFile atomically:YES];

myImage is your UIImage and myFileName is the name you want

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜