UIPageViewController in iOS6

前端 未结 5 1946
野趣味
野趣味 2020-12-24 07:59

In iOS6 in the methods viewControllerAfterViewController and viewControllerBeforeViewController if I return nil (for block the page navigat

5条回答
  •  爱一瞬间的悲伤
    2020-12-24 08:10

    I had the same issue. I found that the cause was replacing the delegate on the UIPanGestureRecognizer of the UIPageViewController, a no-no really. The pan gesture recognizer was calling an undocumented method _gestureRecognizerShouldBegin: (note the leading underscore) that UIPageViewController implements and apparently relies upon to work properly (read: not-crash). I ended up implementing respondsToSelector: and forwardingTargetForSelector: in my class that uses the UIPageViewController to pass the undocumented delegate method on to the UIPageViewController without specifically naming it (and almost certainly earning me an app store review rejection).

    -(BOOL)respondsToSelector:(SEL)aSelector {
        if ([super respondsToSelector:aSelector])
            return YES;
        else if ([self.pageViewController respondsToSelector:aSelector])
            return YES;
        else
            return NO;
    }
    
    - (id)forwardingTargetForSelector:(SEL)aSelector {
        if ([super respondsToSelector:aSelector]) {
            return nil;
        } else if ([self.pageViewController respondsToSelector:aSelector]) {
            return self.pageViewController;
        }
        return nil;
    }
    

    My longer term solution will be to rework the use of UIPageViewController such that I don't need to displace the gesture recognizer delegates.

提交回复
热议问题