Wow, realmente ninguna de estas respuestas funciona. Así es como lo haces para obtener una captura de pantalla de todo, incluido el controlador de navegación
-(void) takeScreenshot
{
CGRect screenRect = [[UIScreen mainScreen] bounds];
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone)
{
//its iphone
CGSize result = [[UIScreen mainScreen] bounds].size;
if(result.height == 480 || result.width == 480)
{
// iPhone Classic
screenRect = CGRectMake(0, 0, 320, 480);
}
if(result.height == 568 || result.width == 568)
{
// iPhone 5
screenRect = CGRectMake(0, 0, 320, 568);
}
}
else
{
//its pad
screenRect = CGRectMake(0, 0, 768, 1024);
}
NSArray* paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString* documentsDirectory = [paths objectAtIndex:0];
// This code is for high resolution screenshot
UIGraphicsBeginImageContextWithOptions(screenRect.size, NO, 0.0);
//this was pre iOS 7.0
//[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
// iOS 7.x -->
[[[[UIApplication sharedApplication] windows] objectAtIndex:0] drawViewHierarchyInRect:self.view.bounds afterScreenUpdates:YES]; // Set To YES
UIImage *viewImage2 = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
NSData* imageData2 = UIImageJPEGRepresentation(viewImage2, 1.0);
NSString* incrementedImgStr2 = [NSString stringWithFormat: @"UserScreenShotPic.jpg"];
// Now we get the full path to the file
NSString* fullPathToFile3 = [documentsDirectory stringByAppendingPathComponent:incrementedImgStr2];
[imageData2 writeToFile:fullPathToFile3 atomically:NO];
}
¿Cómo puedo capturar una captura de pantalla de un controlador de pantalla que incluye la barra de navegación ANTES de presionarlo? Necesito capturar la pantalla completa del controlador de vista de destino. – cschuff
Si tiene un puntero al controlador de vista, puede acceder fácilmente a la vista del controlador de esa vista, incluso si aún no se ha enviado. –
Sí, pero 1. ¿la barra de navegación no pertenece a la vista y 2. no puedo acceder a su barra de navegación antes de que sea presionada? La apariencia de las barras de navegación en VC2 es diferente de VC1. – cschuff