2014-04-24 2 views
0

나는 내가 NSAssert 줄에서 는 나에게 보여주는 오류를 만든 newcontroller와 firstviewcontroller를 변경할 때 그것을 사용하는 동안 로버트 라이언 https://github.com/robertmryan/edge-swipe-demonstration어설 션 오류 사용자 정의 SEGUE

에 의해 에지 출근 데모 클래스와 함께 작동하도록 노력하고 있습니다 여기

내가하는 나는 secondviewcontroller에 끌어 BarButton이 있고 edgeSegu을 선택한 EdgeSwipeSegue.m 코드

@implementation EdgeSwipeSegue 

- (void)perform 
{ 
    UIViewController *source = self.sourceViewController; 
    id <ParentControllerDelegate>parent = (id)source.parentViewController; 
    if(parent==nil){ 
     NSLog(@"Parent is nil"); 
    } 

    NSAssert([parent conformsToProtocol:@protocol(ParentControllerDelegate)], @"Parent does not conform to ParentControllerDelegate; parent = %@", parent); 

    [parent pushChildViewController:self.destinationViewController]; 
} 

입니다 전자하지만 어쩌면 내가 뭔가를 놓치고있다

어설 션이 실패하는 이유는 무엇입니까 ??

답변

0

의 시도하자

// I assume that you have NewViewController 

// in NewViewController.h 
@interface NewViewController : UIViewController <ParentControllerDelegate> 

//in NewViewController.m : just implement method is declared in ParentControllerDelegate 
+0

감사를했다 ...하지만 내가가는 곳에 내가 이해 잘못된. . 내 대답을 게시했습니다 ... 다시 한 번 감사드립니다. – user1201239

0

확인 나는 자신에 의해 그것을 발견 여기에 내가이 hirearchy

- ParentViewController(ContainerView) 
    - NavigationController 
    - Viewcontroller 

했다 대답

그래서이 ID 부모 = (ID) source.parentViewController; 나의

을 요구했다 parentviewcontroller 대신 나를 navigationviewcontroller주고 있었다 그래서이

UIViewcontroller *cont = self.sourceViewController; 
UIViewController *source = con.navigationController; 

처럼 해결하며 소중한 시간을내어