Iphone 尚未成功在两个视图之间创建动画

Iphone 尚未成功在两个视图之间创建动画,iphone,animation,scrollview,Iphone,Animation,Scrollview,我想在两个视图之间创建动画,下面是我所做的: UIView *view1; UIView *view2; view1 = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)]; view2 = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.s

我想在两个视图之间创建动画,下面是我所做的:

  UIView *view1;
    UIView *view2;

view1 = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
    view2 = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];

    self.scrollView1 = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 320)];
    self.scrollView1.pagingEnabled = YES;
    self.scrollView1.delegate = self;
    [view1 addSubview:scrollView1];
    [self.view addSubview:view1];
两个视图都包含相同的scrollView,视图间动画的目的是在scrollView的边之间创建动画

以下是我所做的:

  UIView *view1;
    UIView *view2;

view1 = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
    view2 = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];

    self.scrollView1 = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 320)];
    self.scrollView1.pagingEnabled = YES;
    self.scrollView1.delegate = self;
    [view1 addSubview:scrollView1];
    [self.view addSubview:view1];
当滚动视图到达最后一帧时:

  - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
    {
//here I verify when the last frame of the scrollView is loaded
     if (self.scrollView1.contentOffset.x == self.view.frame.size.width*pathImages.count)         
        {      
            [view1 removeFromSuperview];
            [self.scrollView1 scrollRectToVisible:CGRectMake(self.view.frame.size.width,0 ,self.view.frame.size.width, self.view.frame.size.height) animated:NO];

            [UIView beginAnimations:nil context:NULL];
            [UIView setAnimationDuration:1.0];
            [UIView setAnimationTransition:UIViewAnimationOptionCurveEaseInOut  forView:view2 cache:YES];
            [view2 addSubview:scrollView1];
            [self.view addSubview:view2];
            [UIView commitAnimations];


        }
    }
问题是scrollView是从第一个位置重新加载的,因为它应该是,但是没有动画,只是突然出现。 谁能告诉我错误在哪里以及解决方法。谢谢:

试试看

UIViewAnimationCurveEaseInOut
而不是:

UIViewAnimationOptionCurveEaseInOut
通常,UIViewAnimationOption*与新的、推荐的基于块的动画语法相关联