Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Taking a screenShot/Snapshot programmatically for iOS7 gives me an error

I am writing the code for capturing the screenShot of what I see on my screen when I press a button in Unity.


I am writing the following code :


ScreenCapture.h


#import <Foundation/Foundation.h>


#import <UIKit/UIKit.h>

#import "QuartzCore/QuartzCore.h"


@interface ScreenCaptureDelegate : UIViewController {



}


- (IBAction)ScreenShot;


@end


AND


ScreenCapture.mm


#import "ScreenCapture.h"

#import "QuartzCore/QuartzCore.h"


@implementation ScreenCaptureDelegate


- (IBAction)ScreenShot {

UIGraphicsBeginImageContext(self.view.bounds.size);

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

UIImage *screenshotimage = UIGraphicsGetImageFromCurrentImageContext();

UIGraphicsEndImageContext();

UIImageWriteToSavedPhotosAlbum(screenshotimage, nil, nil, nil);

}


@end


static ScreenCaptureDelegate *delegateObject = nil;


// When native code plugin is implemented in .mm / .cpp file, then functions

// should be surrounded with extern "C" block to conform C function naming rules

extern"C" {

void _showPopUp(const char* Picture)

{

[delegateObjectScreenShot];

}

}



When I run this on the ipad I only get blank images.I have updated my ipad to use ios7.


I even tried with the renderInContext command, even there I get blank images. So i tried with the drawViewHierarchyInRect .


I even used the snapshotViewAfterScreenUpdates but here I dont even get a blank image.


Am i going wrong somewhere?

iOS 7.1.1

Posted on May 7, 2014 3:19 AM

Reply
1 reply

Taking a screenShot/Snapshot programmatically for iOS7 gives me an error

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.