2011-02-05 2 views
1

저는 제한된 성공만으로 며칠 동안이 작업을 수행하는 방법을 알아 내려고 노력했습니다. 나는 뷰 방향이 바뀔 때 알려주는 NSNotifications를 수동으로 처리했다. 그런 다음 CGAffineTransformations를 사용하여 툴바를 올바른 방향으로 이동시킨다. 이런 종류의 작품은 매우 깨끗하지는 않습니다. 그래서 내 질문은, 어떻게 OpenGL을 - ES를보기에 툴바를 추가하고 autototate 수 있습니까? 나는 새로운 viewController를 생성 한 다음이 뷰에 OpenGL 뷰와 툴바를 추가하는 작업을 수행 할 것이라고 생각하지만이 작업을 수행하는 정확한 방법을 알기 위해 뷰와 서브 뷰로 작업하는 데 충분한 경험이 없습니다. . 나는 그것을 시도하고 비참하게 실패했다.툴바 자동 회전으로 OpenGL ES 템플릿을 만드는 방법

답변

2

좋아요, 마침내 알아 냈습니다. 매우 직관적이지는 않지만 작동합니다. http://www.idevgames.com/forums/thread-1773.html

1) 새로운 파일을 추가 ... 코코아 터치 클래스 -> UIViewController 하위, 이름 GLViewController.m에 GLViewController 2), 상단에 # import를 "PaintingView.h"를 추가,이 대답은에서왔다

CGRect rect = [[UIScreen mainScreen] applicationFrame]; 
self.view = [[PaintingView alloc] initWithFrame:CGRectMake(rect.origin.x, rect.origin.y, rect.size.width, rect.size.height)]; 

또한 다운, 변형 확인 : 상기에는 loadView 방법에서, 추가

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOr​ientation { 
    return YES; 
} 

3) AppController.m하여 상단 # import에 "GLViewController.h"을 추가하고, applicationDidFinishLaunching에 다음을 추가합니다.

GLViewController *viewController = [[GLViewController alloc] init]; 
UIToolbar *mainTools = [UIToolbar new]; 
mainTools.frame = CGRectMake(0, 0, 300, 50); 
UIBarButtonItem *newButton = [[UIBarButtonItem alloc] initWithTitle:@"Help!" style:UIBarButtonItemStyleBordered target:self action:nil]; 
[mainTools setItems:[NSArray arrayWithObjects:newButton, nil]]; 
[[viewController view] addSubview:mainTools]; 
[window addSubview:[viewController view]]; 

GL 변환과 터치 좌표를 맞게 변경해야하지만 자동 회전됩니다.

희망 사항은 본인 외에 다른 사람에게 도움이되기를 바랍니다.