Announcements
The Scaleform forum is now read-only. Please head to the Gamedev site for product support.
Scaleform Forum (Read Only)
Scaleform enables developers to leverage the power of the Adobe® Flash® tool set to create powerful user interface environments for video games.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Taking screenshot on IOS

0 REPLIES 0
Reply
Message 1 of 1
Anonymous
435 Views, 0 Replies

Taking screenshot on IOS

Hello!

I've been working on an IOS app that uses the Scaleform Mobile SDK as the rendering backend for a game made entirely in flash. I've been tasked with implimenting a button as part of the game interface that will take a screenshot and save it to the camera roll. I was able to get this working on any device running IOS 7.0 or higher using the following code:

//This works on ios 7 and above

    NSLog(@"Saving screenshot...");

    UIGraphicsBeginImageContextWithOptions(self.view.bounds.size, NO, [UIScreenmainScreen].scale);

    

    [self.view drawViewHierarchyInRect:self.view.bounds afterScreenUpdates:NO];

    

    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();

    UIGraphicsEndImageContext();

    

    UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil);

When I try and run this code on a device running IOS 6.0 or fewer the app will crash. Specifically it crashes on this line:

[self.view drawViewHierarchyInRect:self.view.bounds afterScreenUpdates:NO];

XCode is throwing a NSInvalidArgumentException saying unrecognized selector sent to instance. I've done a bit of research and I should be able to use the following code to take a screenshot on older versions of IOS; however it only saves out a blank white screenshot.

//This works on all things but it saves a white screenshot.

    CGSize imageSize = CGSizeMake(self.view.bounds.size.width, self.view.bounds.size.height);

    UIGraphicsBeginImageContextWithOptions(imageSize, YES, 1.0);

    [self.view.layer renderInContext:UIGraphicsGetCurrentContext()];

    UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();

    UIGraphicsEndImageContext();

    UIImageWriteToSavedPhotosAlbum(viewImage, nil, nil, nil);

 

If anyone knows of a way to make this work I would greatly appreciate it.

0 REPLIES 0

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report