2

我正在尝试使用 ECSLidingViewController2 中的缩放动画设置我的滑动过渡。

就像在 TransitionFun 示例(https://github.com/ECSlidingViewController/ECSlidingViewController/blob/master/Examples/TransitionFun/TransitionFun/METransitionsViewController.m)中一样,我在我的 topView NavigationController 的 viewDidLoad 中执行此操作:

id<ECSlidingViewControllerDelegate> transition = [[MEZoomAnimationController alloc] init];
self.slidingViewController.delegate = transition;

self.slidingViewController.topViewAnchoredGesture = ECSlidingViewControllerAnchoredGestureTapping | ECSlidingViewControllerAnchoredGesturePanning;
self.slidingViewController.customAnchoredGestures = @[];
[self.navigationController.view removeGestureRecognizer:self.dynamicTransitionPanGesture];
[self.navigationController.view addGestureRecognizer:self.slidingViewController.panGesture];

我在 NavigationController 头文件中采用了 ECSlidingViewControllerDelegate 协议。

但它在 ECSlidingViewController.m 中崩溃,在此方法的第一个 if 条件下,我收到 EXC_BAD_ACCESS(1) 错误:

- (CGRect)frameFromDelegateForViewController:(UIViewController *)viewController
                         topViewPosition:(ECSlidingViewControllerTopViewPosition)topViewPosition {
     CGRect frame = CGRectInfinite;

     if ([(NSObject *)self.delegate respondsToSelector:@selector(slidingViewController:layoutControllerForTopViewPosition:)]) {
    id<ECSlidingViewControllerLayout> layoutController = [self.delegate slidingViewController:self
                                                           layoutControllerForTopViewPosition:topViewPosition];

    if (layoutController) {
        frame = [layoutController slidingViewController:self
                                 frameForViewController:viewController
                                        topViewPosition:topViewPosition];
    }
}

return frame;

}

有人有同样的问题吗?谢谢

4

1 回答 1

1

这就是我在视图控制器的 viewDidLoad: 方法中所做的,效果很好:

id<ECSlidingViewControllerDelegate> transition = self.zoomAnimationController;
self.slidingViewController.delegate = transition;
self.slidingViewController.topViewAnchoredGesture = ECSlidingViewControllerAnchoredGestureTapping | ECSlidingViewControllerAnchoredGesturePanning;
self.slidingViewController.customAnchoredGestures = @[];
[self.navigationController.view addGestureRecognizer:self.slidingViewController.panGesture];

如果像我一样,你不想实现动态转换,你应该去掉你说的那一行:

[self.navigationController.viewremoveGestureRecognizer:self.dynamicTransitionPanGesture];

恕我直言,它可能导致您的 EXC_BAD_ACCESS(1) 错误,因为您实际上没有设置 dynamicTransitionPanGesture 手势识别器。

于 2014-02-15T22:06:40.717 回答