2010-04-10 3 views
2

메모리 내 이미지 버퍼에 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]; 

, 오프 스크린 메모리 버퍼의 내용이 세로 지향적, 윈도우가 가로 방향의 경우에도.

아이디어가 있으십니까?

답변

1

MyUIViewController은 가로 방향으로보기의 하위보기를 어떻게 배치합니까?

마스크를 자동 크기 조정에만 의존하는 경우 인터페이스 방향이 가로 인 경우 렌더링하기 전에 controller.view.bounds = CGRectMake(480,300) (또는 iPad의 해당 rect)을 직접 설정할 수 있습니다.

추가 레이아웃 코드 (예 : -[MyUIViewController willAnimateRotationToInterfaceOrientation:duration:])가있는 경우 렌더링하기 전에 호출해야하는지 확인해야합니다.

+0

실무 위대한! 여기에 내가 추가 한 코드가 있습니다 : UIInterfaceOrientation orientation = [UIDevice currentDevice] .orientation; if (orientation == UIInterfaceOrientationLandscapeLeft || orientation == UIInterfaceOrientationLandscapeRight) { controller.view.bounds = CGRectMake (0, 0, 1024,768); } – Aaron

관련 문제