2012-10-24 3 views
0

여기에 증강 현실 기능을 앱에 통합해야합니다. 별도로 테스트 한 후에 이제이를 통합 할 준비가되었습니다. 응용 프로그램은 항상 세로로 실행됩니다. 가로 세로 또는 가로로 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! 

답변

1

내가보기에 나쁘다.

- (void)deviceOrientationDidChange:(NSNotification *)notification 

더 이상 :

내가 디버거 중단 점을 사용하고 중요한 순서를 반복, 내가 입력되지 않았습니다 발견했다.따라서 이것이 처음으로 본 것입니다. 기기 방향 변경에 대한 청취자가 갑자기 발사를 중지합니다.

if (orientation == UIDeviceOrientationLandscapeLeft) { 
     NSLog(@"ViewController Landscape left"); 
     [[UIDevice currentDevice] endGeneratingDeviceOrientationNotifications]; 
     [[NSNotificationCenter defaultCenter] removeObserver:self]; 
     ARViewController *arVC = [[ARViewController alloc] initWithNibName:@"ARViewController" bundle:nil]; 
     [self setCameraViewController:arVC]; 
     arVC = nil; 
     [cameraViewController setModalTransitionStyle: UIModalTransitionStyleFlipHorizontal]; 
     [[super navigationController] presentModalViewController:cameraViewController animated:YES]; 
} 

그리고 난의 ViewController를 사용하고 있습니다 때마다 (호출보기 : 결과적으로 내 솔루션은 매우 잔인하지만 적어도이 문제를 정지의 장점이 바로 장치 방향의 변화를 검출 한 후 나는 리스너를 중지 컨트롤러), I는 리스너를 다시 초기화, 그것은 viewDidAppear:

// Listen for changes in device orientation 
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(deviceOrientationDidChange:) name: UIDeviceOrientationDidChangeNotification object:nil]; 
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications]; 

에 잘 지금은 해결 될하지만 난 솔루션의 같은 종류를 찾는 실망 인정해야 의미합니다.

0

글쎄, 내가 전에 ARC를 사용한 적이 있지만, 내가 무엇을보고에 따라, 당신은 초기화 ARViewController는 방향을 변경할 때마다 (가로 방향) 2 개의 ARViewController를 인스턴스화하지 않고 매번 호출하는 것이 어떻습니까?

인물로 전환 할 때마다 사진이 공개되는 것을 확인한 경우를 제외하고는 예외입니다.

게다가 그냥 pushViewController : animated :?

그리고 마지막으로 한 가지는 navigationController에 presentModalViewController를 표시하지만 [super presentingViewController]에서이를 제거하면 어쩌면 추가 할 수 있습니까?

+0

나는 pushViewController를 시도했다. 처음에는 AR을 표시하는 가장 확실한 방법으로 보였다. 하지만 내 응용 프로그램 오리 엔테이션 제한 (프로젝트 설정)에만 초상화가 있기 때문에, 나는 아칸소, 3/4 영역의 영역 touchesBegan, 이상한에 대한 활성화됩니다 ... 모달과 함께 잘 작동합니다. 그것 없이는 pushViewController를 사용했을 것입니다. 그리고 네가 말한 kast에서 네가 의미하는 것을 얻지 못해서 미안해. –

+0

죄송합니다, 나는 당신이 [super presentingViewController] 코드를 게시 할 수 있음을 의미합니다. – Snaker

+0

죄송 합니다만, 귀하의 최신 경고와 충분히 근접한 유일한 발견은 [this]입니다 (http://stackoverflow.com/questions/12596882/modal). -winavigationcontroller-hides-but-not-dismisses) – Snaker

관련 문제