ECSlidingViewController 缩放动画
Posted
技术标签:
【中文标题】ECSlidingViewController 缩放动画【英文标题】:ECSlidingViewController Zoom Animation 【发布时间】:2014-02-15 13:09:48 【问题描述】:我正在尝试使用 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;
有人遇到同样的问题吗? 谢谢
【问题讨论】:
【参考方案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 手势识别器。
【讨论】:
谢谢,您的代码对我有用。但我认为`EXC_BAD_ACCES以上是关于ECSlidingViewController 缩放动画的主要内容,如果未能解决你的问题,请参考以下文章
ECSlidingViewController - 你怎么知道菜单何时显示?
ECSlidingViewController 冻结 UIRefreshControl
ecslidingviewcontroller和uislider
带有 UIScrollView 的 ECSlidingViewController
使用 ECSlidingViewController 在 MenuController 上激活平移手势
ECSlidingViewController - 将 UITableView 和 segue 添加到另一个 ViewController