Cha*_*e S 5 avfoundation uiviewcontroller mkmapview ios presentviewcontroller
我UIViewControllerTransitioningDelegate用来在两个视图控制器(从a MKMapView)到构建在(AVFoundation)上的自定义Camera 之间构建自定义转换.一切顺利,直到我打电话presentViewController,手机似乎挂了大约1秒钟(当我记录所有东西时).这甚至似乎发生在我转换到更简单的视图时(我有一个视图控制器只显示一个UITextview,甚至在实际调用转换之前似乎有大约.4 - .5秒的延迟).
这是我现在称之为过渡的方式
dispatch_async(dispatch_get_main_queue(), ^{
UIStoryboard* sb = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
CameraViewController *cvc2 = [sb instantiateViewControllerWithIdentifier:@"Camera"];
cvc2.modalPresentationStyle = UIModalPresentationFullScreen; // Needed for custom animations to work
cvc2.transitioningDelegate = self; //Conforms to the UIViewControllerTransitioningDelegate protocol
[self presentViewController:cvc2 animated:YES completion:nil];
});
Run Code Online (Sandbox Code Playgroud)
这是我animateTransition打电话的方法.非常直接,目前呈现此视图的视图上只有一个MkMapView(没有其他视图或方法).
-(void)animateTransition:(id<UIViewControllerContextTransitioning>)transitionContext {
if (self.type == MapAnimationTypePresent) {//From map to another view
UIView *containerView = [transitionContext containerView];
UIViewController *fromViewController = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey];
UIViewController *toViewController = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey];
// Amazing category for iOS 7 compatibility found here - http://stackoverflow.com/a/25193675/2939977
UIView *toView = [toViewController viewForTransitionContext:transitionContext];
UIView *fromView = [fromViewController viewForTransitionContext:transitionContext];
toView.frame = self.view.frame;
fromView.frame = self.view.frame;
//Add 'to' view to the hierarchy
toView.alpha = 0;
[containerView insertSubview:toView aboveSubview:fromView];
[UIView animateWithDuration:.5 animations:^{
toView.alpha = 1;
}completion:^(BOOL finished) {
[transitionContext completeTransition:YES];
}];
}
Run Code Online (Sandbox Code Playgroud)
任何帮助是极大的赞赏.
| 归档时间: |
|
| 查看次数: |
1953 次 |
| 最近记录: |