0

私は通常スタックオーバーフローですべての答えを見つけますが、今回はそうではないので、これは私の最初の投稿です!

少し問題があります。

私は次の方法を使用しています:

    -(void)scrollToTop;
{
    [_scrollView setContentOffset:CGPointZero animated:YES];
}

時々それは時々アニメートしない!

これは動作します:

-(void)newPage:(NSString*)href
{

    if(!(_pageNumber == href.integerValue))
    {
        __weak id weakSelf = self;

        [(PageViewController*)_preLoadPages[href] setPageMinHeight:_actualPage.height];

        NSMutableArray *viewControllers = [[NSMutableArray alloc] init];
        viewControllers[0] = _preLoadPages[href];
        [self.pageViewController setViewControllers:viewControllers direction:UIPageViewControllerNavigationDirectionForward animated:YES completion:^(BOOL finished){

            [weakSelf afterLinkClicked:href];

        }];

        _pageNumber = href.integerValue;
    }
}
- (void)afterLinkClicked:(NSString*)href
{
    _pageNumber = href.integerValue;

    [_preLoadPages[href] setPageMinHeight:0];
    _actualPage = _preLoadPages[href];
    [_preLoadPages removeAllObjects];
    [self updateScrollView];
    [self scrollToTop];

    [self parsePage];
}

これはそうではありませんが:

- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer
{

    CGPoint test = [gestureRecognizer locationInView:gestureRecognizer.view];
    if(test.x>=742)
    {
        if(_preLoadPages[@"next"]!=nil)
        {
            __weak id weakSelf = self;

            [(PageViewController*)_preLoadPages[@"next"] setPageMinHeight:_actualPage.height];

            NSMutableArray *viewControllers = [[NSMutableArray alloc] init];
            viewControllers[0] = _preLoadPages[@"next"];
            [self.pageViewController setViewControllers:viewControllers direction:UIPageViewControllerNavigationDirectionForward animated:YES completion:^(BOOL finished){

                [weakSelf afterAnimationCompleted];

            }];
        }
    }

    return YES;
}
- (void)afterAnimationCompleted
{
    _pageNumber++;
    [_preLoadPages[@"next"] setPageMinHeight:0];
    _actualPage = _preLoadPages[@"next"];
    [_preLoadPages removeAllObjects];
    [self updateScrollView];
    [self scrollToTop];

    [self parsePage];
}

これらの2つの呼び出しの間に実質的な違いはありません!私はperformSelector:withObject:withDelay:0を使おうとしましたが、うまくいきません!!

4

0 に答える 0