J'essaye de rendre une vue en mémoire (mais pas dans la hiérarchie, pourtant) de UIViewController dans un tampon d'image en mémoire ainsi je peux faire quelques animations de transition intéressantes. Cependant, quand je rends la vue de UIViewController dans ce tampon, il est toujours rendu comme si le contrôleur était en orientation Portrait, peu importe l'orientation du reste de l'application. Comment puis-je trouver ce contrôleur?Comment est-ce que je peux rendre le paysage de vue d'UIViewController dans la mémoire?
Mon code RootViewController ressemble à ceci:
MyUIViewController* controller = [[MyUIViewController alloc] init];
int width = self.view.frame.size.width;
int height = self.view.frame.size.height;
int bitmapBytesPerRow = width * 4;
unsigned char *offscreenData = calloc(bitmapBytesPerRow * height, sizeof(unsigned char));
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
CGContextRef offscreenContext = CGBitmapContextCreate(offscreenData, width, height, 8, bitmapBytesPerRow, colorSpace, kCGImageAlphaPremultipliedLast);
CGContextTranslateCTM(offscreenContext, 0.0f, height);
CGContextScaleCTM(offscreenContext, 1.0f, -1.0f);
[(CALayer*)[controller.view layer] renderInContext:offscreenContext];
À ce moment-là, les tampons de mémoire contenus sont-hors écran orienté portrait, même lorsque la fenêtre est en orientation paysage.
Des idées?
A travaillé super! Voici le code que j'ai ajouté: UIInterfaceOrientation orientation = [UIDevice currentDevice] .orientation; if (orientation == UIInterfaceOrientationLandscapeLeft || orientation == UIInterfaceOrientationLandscapeRight) { controller.view.bounds = CGRectMake (0, 0, 1024,768); } – Aaron