2016-12-12 7 views
0

https://github.com/cwRichardKim/RKSwipeBetweenViewControllers을 사용하여 내 컨트롤러를 스 와이프합니다. 모든 일이 잘 실행됩니다. UIButton을 추가하고 싶습니다. 스 와이프없이 다른보기 컨트롤러로 이동할 수 있습니다. 아래 코드를 사용하여 uibutton을 만드는 RKSwipeBetweenViewControllers 클래스를 가져 왔습니다.RKSwipeBetweenViewControllers (GitHub)에서 셀렉터 메서드를 호출하는 방법

UIButton *button = [[UIButton alloc]initWithFrame:CGRectMake(X_BUFFER+i*(self.view.frame.size.width-2*X_BUFFER)/numControllers-X_OFFSET, Y_BUFFER, (self.view.frame.size.width-2*X_BUFFER)/numControllers, HEIGHT)]; 

     [navigationView addSubview:button]; 

     [button addTarget:self action:@selector(tapSegmentButtonAction:) forControlEvents:UIControlEventTouchUpInside]; 

     [button setTitle:[buttonText objectAtIndex:i] forState:UIControlStateNormal]; 

과 선택 방법은 다음과 같습니다 : 난 내보기 컨트롤러에서이 메소드를 호출 할 때 RKSwipeBetweenViewControllers에서와 같이

-(void)tapSegmentButtonAction:(UIButton *)button { 

    if (!self.isPageScrollingFlag) { 

     NSInteger tempIndex = self.currentPageIndex; 

     __weak typeof(self) weakSelf = self; 

     //%%% check to see if you're going left -> right or right -> left 
     if (button.tag > tempIndex) { 

      //%%% scroll through all the objects between the two points 
      for (int i = (int)tempIndex+1; i<=button.tag; i++) { 
       [pageController setViewControllers:@[[viewControllerArray objectAtIndex:i]] direction:UIPageViewControllerNavigationDirectionForward animated:YES completion:^(BOOL complete){ 

        //%%% if the action finishes scrolling (i.e. the user doesn't stop it in the middle), 
        //then it updates the page that it's currently on 
        if (complete) { 
         [weakSelf updateCurrentPageIndex:i]; 
        } 
       }]; 
      } 
     } 

     //%%% this is the same thing but for going right -> left 
     else if (button.tag < tempIndex) { 
      for (int i = (int)tempIndex-1; i >= button.tag; i--) { 
       [pageController setViewControllers:@[[viewControllerArray objectAtIndex:i]] direction:UIPageViewControllerNavigationDirectionReverse animated:YES completion:^(BOOL complete){ 
        if (complete) { 
         [weakSelf updateCurrentPageIndex:i]; 
        } 
       }]; 
      } 
     } 
    } 
} 

은 이제 동일한 방식으로 응답하지 않습니다.

다음은이 선택기 메서드를 호출하는 데 사용하는 코드입니다.

[rkSwipeControllrObject tapSegmentButtonAction:myButtonObject]; 

답변

0

나는 당신이 RKSwipeBetweenViewControllers.h 파일이 선언하여 "tapSegmentButtonAction"방법 공개했다 바랍니다.