screenshots programmatically in IPad with the image name

前端 未结 1 1370
天涯浪人
天涯浪人 2021-01-22 12:29

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.<

相关标签:
1条回答
  • 2021-01-22 12:51

    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 讨论(0)
提交回复
热议问题