开发者

screenshots programmatically in IPad with the image name

开发者 https://www.devze.com 2023-01-24 03:42 出处:网络
how to save the screenshot programmatically in Ipad with image nametaken from the user? i\'ve found a snippet which works but doesn\'t asks for the name of the image开发者_开发问答.

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

精彩评论

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