여기에 증강 현실 기능을 앱에 통합해야합니다. 별도로 테스트 한 후에 이제이를 통합 할 준비가되었습니다. 응용 프로그램은 항상 세로로 실행됩니다. 가로 세로 또는 가로로 iPhone을 회전시킬 때 증강 현실을 표시하기로 결정했습니다. 물론 세로보기로 돌아 가면 원래보기 컨트롤러가 표시됩니다. 실제로 증강 현실은 모달로 표현됩니다.모달 뷰 컨트롤러는 2/3 배 더 이상 제공되지 않습니다.
ARViewController (모달리)를 호출하는 viewController가 있습니다. 2 ~ 3 번 회전하면 정상적으로 작동하지만이 ARViewController는 더 이상 호출되지 않지만 앱이 계속 실행되고 크래시가 발생하지 않고 멈추지 않습니다. 이 ARViewController는 증강 현실에 필요한 모든 것을 계산하는 클래스 인 ARController로 초기화됩니다. ARController없이이 ARViewcontroller를 호출하면 View Controller 사이를 전환하면 아주 잘 작동하지만 빈 창이 호출되지만 적어도 원하는만큼 장치를 회전시킬 수 있습니다. 그래서 이것은 ARController에서 온 것이어야합니다. (ARC를 사용하는 방식으로) 메모리 누수에 대해 문서화했습니다.이 ARController를 여러 번 사용하고 있기 때문에 이것이 문제의 원인이 될 수 있다고 생각합니다.
다음내가의 ViewController에 ARViewController를 호출하는 방법입니다 :
은그러나 더 가기 전에, 내가보기 컨트롤러 사이를 전환하여 ARController에 영향을 줄 수있는 뭔가 잘못하고 있어요 있는지 알고 싶습니다
if (orientation == UIDeviceOrientationLandscapeLeft) {
NSLog(@"ViewController Landscape left");
ARViewController *arVC = [[ARViewController alloc] initWithNibName:@"ARViewController" bundle:nil];
[self setCameraViewController:arVC];
[arVC setModalTransitionStyle: UIModalTransitionStyleFlipHorizontal];
[[self navigationController] presentModalViewController:cameraViewController animated:YES];
arVC = nil;
}
else if (orientation == UIDeviceOrientationLandscapeRight) {
NSLog(@"ViewController Landscape Right");
ARViewController *arVC = [[ARViewController alloc] initWithNibName:@"ARViewController" bundle:nil];
[self setCameraViewController:arVC];
[arVC setModalTransitionStyle: UIModalTransitionStyleFlipHorizontal];
[[self navigationController] presentModalViewController:cameraViewController animated:YES];
arVC = nil;
}
ARViewController의 초기화 : I가 회전하면 내가 원래 뷰 컨트롤러로 돌아갈 방법을 마침내 여기
- (void)viewDidLoad {
[super viewDidLoad];
self.arController = [[ARController alloc] initWithViewController:self];
arController.filterDiscover = filterDiscover;
arController.filterEat = filterEat;
arController.filterSleep = filterSleep;
// Listen for changes in device orientation
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(deviceOrientationDidChange:) name: UIDeviceOrientationDidChangeNotification object:nil];
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
//if ViewController presents this modal ARViewController
if(!arController.filterDiscover && !arController.filterEat && !arController.filterSleep)
[arController callAlertViewToFilter];
else
[arController loadData];
}
그리고는 ARViewController에서 세로 : 사람이 비슷한 문제를 가지고 어느 경우 나는 가능한 한 명확하게하려고
if (orientation == UIDeviceOrientationPortrait){
NSLog(@"ARViewController Portrait");
[self setArController:nil];
[[super presentingViewController] dismissModalViewControllerAnimated:YES];
}
, 그것은 큰이이 문제를 해결하기 위해 몇 가지 단서가 될 수 있습니다. 나는 ARController의 코드를 보여줄 수 있었지만 조금 길었다. 왜냐하면 여기에 잘못된 것이 있는지를 알고 싶기 때문이다. 필요한 경우 보여 드리겠습니다. ARViewController 더 이상 표시되지 않을 때이 도움이 될
, 나는 디버그 지역에서이 출력을 발견2012-10-24 17:57:51.072 beiceland[20348:907] ViewController Landscape Right
2012-10-24 17:57:51.073 beiceland[20348:907] Warning: Attempt to present <ARViewController: 0x203f0c60> on <RevealController: 0x1cd5dca0> while a presentation is in progress!
나는 pushViewController를 시도했다. 처음에는 AR을 표시하는 가장 확실한 방법으로 보였다. 하지만 내 응용 프로그램 오리 엔테이션 제한 (프로젝트 설정)에만 초상화가 있기 때문에, 나는 아칸소, 3/4 영역의 영역 touchesBegan, 이상한에 대한 활성화됩니다 ... 모달과 함께 잘 작동합니다. 그것 없이는 pushViewController를 사용했을 것입니다. 그리고 네가 말한 kast에서 네가 의미하는 것을 얻지 못해서 미안해. –
죄송합니다, 나는 당신이 [super presentingViewController] 코드를 게시 할 수 있음을 의미합니다. – Snaker
죄송 합니다만, 귀하의 최신 경고와 충분히 근접한 유일한 발견은 [this]입니다 (http://stackoverflow.com/questions/12596882/modal). -winavigationcontroller-hides-but-not-dismisses) – Snaker