質問

私は動的に変化するデータソースを持つUIPageViewControllerを持っています -

ViewControllerAfterViewController

ViewControllerBeForeviewController

データがまだ準備ができていない場合はNILを返し、レディの準備ができている場合はView Controllerを返します。いくつかのPointでは、ページをすばやく複数回左に置かないようにした場合、ViewControllerAfterViewControllerはこれ以上呼び出されていません。

問題になることができる?UipageViewControllerがすべてを知っていると考えると思います。このキャッシュを「リセット」できますか?

CURL遷移スタイルを使用し、これはランドスケープモードでのみ起こるようです。

役に立ちましたか?

解決

私は自分のスワイプジェスチャーを使って終わった。

  1. 最初に既存のスワイプジェスチャを削除UIPageViewController

    for (UIGestureRecognizer * recognizer in _pageViewController.gestureRecognizers) {
        recognizer.enabled = NO;
    }
    
  2. それからあなた自身のスワイプジェスチャ認識をuipageViewController

    に追加します。
    UISwipeGestureRecognizer * rightRecognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleRightSwipe:)];
    [rightRecognizer setDirection:(UISwipeGestureRecognizerDirectionLeft)];
    [_pageViewController.view addGestureRecognizer:rightRecognizer];
    
    UISwipeGestureRecognizer * leftRecognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleLeftSwipe:)];
    [leftRecognizer setDirection:(UISwipeGestureRecognizerDirectionRight)];
    [_pageViewController.view addGestureRecognizer:leftRecognizer];
    
    - (void) handleRightSwipe: (id) sender {
    // your swipe handler here 
    // note that you need  to call didFinishAnimating manually now
    
    // manually calculate next/prev view controller, also you should consider orientation too
     UIViewController * nextController = [_modelController pageViewController:_pageViewController viewControllerAfterViewController:existingController];
    
    
    __weak typeof(self) weakSelf = self;
    __weak UIPageViewController * wController = _pageViewController;
    [_pageViewController setViewControllers:@[nextController] direction:
        UIPageViewControllerNavigationDirectionForward animated:YES completion:^(BOOL completed){
            [weakSelf pageViewController:wController didFinishAnimating:YES previousViewControllers:@[existingController] transitionCompleted:YES];
        }];
      }
     }
    
  3. また、既存のスワイプジェスチャを削除しないようにしても、カスタムスワイプジェスチャーを呼び出さないように見えます。すべての認識者を削除します。

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top