Ios 7自定义UINavigationController动画在目标控制器中的mapView中失败
我正在玩新的Ios 7自定义UINavigationController动画在目标控制器中的mapView中失败,ios,animation,ios7,uiviewcontroller,custom-transition,Ios,Animation,Ios7,Uiviewcontroller,Custom Transition,我正在玩新的UIViewControllerContextTransitioning在UViewController内部UINavigationViewController 我所拥有的和我想要实现的都很简单,但我在某个地方失败了 我在UIScrollView中有一个MKMapView(300px*60px)。单击该地图(无论它在可见滚动条中的何处),我想切换到下一个包含完整大小的MKMapView的视图。 我想要的感觉和动画是让用户感觉他们被吸入地图(有点)=) 到目前为止,我补充说: 及 最
UIViewControllerContextTransitioning
在UViewController
内部UINavigationViewController
我所拥有的和我想要实现的都很简单,但我在某个地方失败了
我在UIScrollView
中有一个MKMapView
(300px*60px)。单击该地图(无论它在可见滚动条中的何处),我想切换到下一个包含完整大小的MKMapView
的视图。
我想要的感觉和动画是让用户感觉他们被吸入地图(有点)=)
到目前为止,我补充说:
及
最后我有了“FixRTransitionAnimator.m”``
-(NSTimeInterval)transitionDuration:(id<UIViewControllerContextTransitioning>)transitionContext{
NSLog(@"the time is timed");
return 0.5f;
}
-(void)animateTransition:(id<UIViewControllerContextTransitioning>)transitionContext{
NSLog(@"we are inside %@",NSStringFromCGRect(self.mapFrame));
UIViewController *fromVController = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey];
UIViewController *toVController = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey];
CGRect endFrame = CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width,[UIScreen mainScreen].bounds.size.height);
if (self.presenting) {
fromVController.view.userInteractionEnabled = NO;
[[transitionContext containerView]addSubview:fromVController.view];
[[transitionContext containerView]addSubview:toVController.view];
toVController.view.frame = self.mapFrame;
[UIView animateWithDuration:[self transitionDuration:transitionContext] animations:^{
fromVController.view.tintAdjustmentMode = UIViewTintAdjustmentModeDimmed;
NSLog(@"inside the animation");
toVController.view.frame = endFrame;
} completion:^(BOOL finished) {
[transitionContext completeTransition:YES];
}];
}else{
...
}
}
-(NSTimeInterval)transitionDuration:(id)transitionContext{
NSLog(@“时间已计时”);
返回0.5f;
}
-(void)animateTransfion:(id)transitionContext{
NSLog(@“我们在%@”,NSStringFromCGRect(self.mapFrame));
UIViewController*fromVController=[transitionContext ViewControllerWorky:UITransitionContextFromViewControllerKey];
UIViewController*toVController=[transitionContext ViewControllerWorky:UITransitionContextToViewControllerKey];
CGRect endFrame=CGRectMake(0,0[UIScreen mainScreen].bounds.size.width[UIScreen mainScreen].bounds.size.height);
如果(自我介绍){
fromVController.view.userInteractionEnabled=否;
[[transitionContext containerView]添加子视图:来自vController.view];
[[transitionContext containerView]添加子视图:toVController.view];
toVController.view.frame=self.mapFrame;
[UIView animateWithDuration:[self-transitionDuration:transitionContext]动画:^{
fromVController.view.tintAdjustmentMode=UIViewTintAdjustmentMode变暗;
NSLog(@“动画内部”);
toVController.view.frame=结束帧;
}完成:^(布尔完成){
[transitionContext completeTransition:是];
}];
}否则{
...
}
}
当destinationViewController为空时,过渡动画效果良好。但是动画里面的地图真的很奇怪,根本不是我想要的
Any1得到了我错过或需要思考的东西的任何提示吗?我在另一篇文章中写了一篇文章,但请确保您正在设置UINavigationControllerDelegate
显示的控制器有一个
UIViewControllerTransitioningDelegate
,推送的控制器有一个UINavigationControllerDelegate
。协议中的委托方法返回您的动画师。是的,就是这样。但是,自从我发布了q=)tnx之后,我对API有了更多的了解!
[super prepareForSegue:sender sender:sender];
MapViewController *mapViewController = segue.destinationViewController;
mapViewController.transitioningDelegate = self;
mapViewController.modalPresentationStyle = UIModalPresentationCustom;
-(NSTimeInterval)transitionDuration:(id<UIViewControllerContextTransitioning>)transitionContext{
NSLog(@"the time is timed");
return 0.5f;
}
-(void)animateTransition:(id<UIViewControllerContextTransitioning>)transitionContext{
NSLog(@"we are inside %@",NSStringFromCGRect(self.mapFrame));
UIViewController *fromVController = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey];
UIViewController *toVController = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey];
CGRect endFrame = CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width,[UIScreen mainScreen].bounds.size.height);
if (self.presenting) {
fromVController.view.userInteractionEnabled = NO;
[[transitionContext containerView]addSubview:fromVController.view];
[[transitionContext containerView]addSubview:toVController.view];
toVController.view.frame = self.mapFrame;
[UIView animateWithDuration:[self transitionDuration:transitionContext] animations:^{
fromVController.view.tintAdjustmentMode = UIViewTintAdjustmentModeDimmed;
NSLog(@"inside the animation");
toVController.view.frame = endFrame;
} completion:^(BOOL finished) {
[transitionContext completeTransition:YES];
}];
}else{
...
}
}