我有一个 UIViewController ,其中包含 2 个 UIScrollViewsscrollView1scrollView2 例如。
scrollView1 包含许多 UIViews ,当点击其中一个是 UIViews 时,我希望它进入 scrollView2
当点击属于 UIViewscrollView1 时,会调用 UIViewController 内部的方法,并将 view 作为参数传递。

最佳答案

在该方法中,您应该编写如下内容:

[view removeFromSuperview];
[scrollView2 addSubview:view];

编辑 :

对于动画移动,您应该尝试以下操作:
CGPoint originalCenter = [self.view convertPoint:view.center fromView:scrollView1];
[view removeFromSuperView];
[self.view addSubview:view];
view.center = originalCenter;

CGPoint destinationPointInSecondScrollView = ; // Set it's value
CGPoint finalCenter = [self.view convertPoint:destinationPointInSecondScrollView fromView:scrollView2];
[UIView animateWithDuration:0.3
                      delay:0
                    options:UIViewAnimationOptionCurveEaseInOut
                 animations:^{
                     view.center = finalCenter;
                 } completion:^(BOOL finished) {
                         [view removeFromSuperView];
                         [scrollView2 addSubview:view];
                         view.center = destinationPointInSecondScrollView;
                     }];

10-06 02:56