메모리 내 이미지 버퍼에 UIViewController의 뷰를 인라인 (그러나 계층 구조는 아니지만) 렌더링하려고하므로 흥미로운 전환 애니메이션을 수행 할 수 있습니다. 그러나 UIViewController의 뷰를 해당 버퍼로 렌더링 할 때 컨트롤러의 세로 방향, 즉 나머지 응용 프로그램의 방향에 관계없이 항상 렌더링됩니다. 어떻게이 컨트롤러를 단서에 넣을 수 있습니까?메모리 내 UIViewController의 가로 뷰를 렌더링하는 방법은 무엇입니까?
RootViewController에서 내 코드는 다음과 같습니다 : 그 시점에서
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];
, 오프 스크린 메모리 버퍼의 내용이 세로 지향적, 윈도우가 가로 방향의 경우에도.
아이디어가 있으십니까?
실무 위대한! 여기에 내가 추가 한 코드가 있습니다 : UIInterfaceOrientation orientation = [UIDevice currentDevice] .orientation; if (orientation == UIInterfaceOrientationLandscapeLeft || orientation == UIInterfaceOrientationLandscapeRight) { controller.view.bounds = CGRectMake (0, 0, 1024,768); } – Aaron