2013-01-21 3 views
0

이 사용자 정의 segue는 시각적으로 올바르게 작동하지만 완료되면 경고가 표시됩니다.사용자 정의 segue에서 다른 UIViewController로 전환

Warning: Attempt to present <DestViewController: 0x21059f40> on <SrcViewController: 0x1fd50cf0> whose view is not in the window hierarchy! 

경고없이 작동하게하는 방법에 대한 도움을 받으려면 내가 받아야 할 것보다 더 많은 시간을 할애해야합니다. 그것이 경고이기 때문에 나는 그것에 관하여 걱정해야하는지 확실하지 않다. 의 src의 UIViewController의 리셋 방법에 MPMoviePlayerController를 중지 호출이 있었다

- (void)perform { 
    UIViewController *src = (UIViewController *)self.sourceViewController; 
    UIViewController *dst = (UIViewController *)self.destinationViewController; 

    dst.view.alpha = 0; 

    [UIView animateWithDuration:0.5 
       animations:^{ 
        [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut]; 
        [src.view addSubview:dst.view]; 
        dst.view.alpha = 1; 
       } 
       completion:^(BOOL finished){ 
        [dst.view removeFromSuperview]; 
        //need to understand why this throws a warning but still works 
        [src presentViewController:dst animated:NO completion:^(){ 
         [src reset]; 
        }]; 
       }]; 
} 

UPDATE

. 그것이 문제를 일으키는 어떤 이유로, 일단 제거되면이 segue가 완벽하게 작동합니다. segue의 최종 구현은 아래의 내 대답을 참조하십시오.

답변

0

, 위에서 언급 한 바와 같이, 나는 전체 작업 SEGUE를 게시 할 것이라고 생각 여기서 끝낼 수있는 다른 사람들을위한 코드. 이 예에서 위임 자식 UIViewContainers는 다음과 같은 방법으로 아이들로 추가 사용자 정의 UIViewController에 컨테이너입니다 :

[self addChildViewController:childController_]; 
[self.view addSubview:childController_.view]; 

segue.h

#import <UIKit/UIKit.h> 

@interface COFSimpleSegue : UIStoryboardSegue 

@property (assign) UIViewController *delegate; 

@end 

segue.m

#import "COFSimpleSegue.h" 
#import <QuartzCore/QuartzCore.h> 

@implementation COFSimpleSegue 

@synthesize delegate = delegate_; 

- (void)perform { 
    UIViewController *src = (UIViewController *)self.sourceViewController; 
    UIViewController *dst = (UIViewController *)self.destinationViewController; 

    dst.view.frame = delegate_.view.bounds; 
    dst.view.autoresizingMask = delegate_.view.autoresizingMask; 

    [src willMoveToParentViewController:nil]; 

    [delegate_ 
     transitionFromViewController:src 
     toViewController:dst 
     duration:0.5f 
     options:UIViewAnimationOptionTransitionCrossDissolve 
     animations:^(void){} 
     completion:^(BOOL finished) { 
     [dst didMoveToParentViewController:delegate_]; 
     [src removeFromParentViewController]; 
     } 
    ]; 
} 

@end 
0

superview 즉 src.view에서보기를 제거하고 그 뒤에 동일한 viewController를 표시하므로 경고가 표시됩니다. (이 말해 작동하지 않는 경우)

이 시도 : 원래 문제가 SEGUE 이외의 무언가에 의해 발생되었지만

[UIView animateWithDuration:0.5 
       animations:^{ 
        [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut]; 
        dst.view.alpha = 1; 
       } 
       completion:^(BOOL finished){ 
        [src presentViewController:dst animated:NO completion:^(){ 
         [src reset]; 
        }]; 
       }]; 
} 
+0

을 도움이나 상처를 입지 않았다. 나는 두 줄의 코드를 제거했고 정확히 똑같이 작동하고 여전히 같은 경고를줍니다. – chris

+0

[src reset] 내부에 쓰여진 내용을 제공해 주실 수 있습니까? –

+0

재설정시 MPMoviePlayerController를 중지하라는 호출이있었습니다. 일단 내가 그것을 제거 했어. dst 뷰를 추가 한 다음 애니메이션이 다르게 발생하지 않았으므로 완전한 블록에서 제거하는 두 줄의 코드를 다시 넣어야했습니다. 당신의 도움을 주셔서 감사합니다. – chris

관련 문제