【问题标题】:haven't succed to create animation between two views尚未成功在两个视图之间创建动画
【发布时间】:2011-12-03 12:41:29
【问题描述】:

我想在两个视图之间创建一个动画,这就是我所做的:

两个视图都包含相同的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];

scrollView到达最后一帧时:

  - (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];


        }
    }

问题是滚动视图再次从第一个位置加载(应该如此)但没有动画 - 只是突然出现。 谁能告诉我错误在哪里以及解决方法。谢谢:)

【问题讨论】:

    标签: iphone animation scrollview


    【解决方案1】:

    试试

    UIViewAnimationCurveEaseInOut
    

    代替:

    UIViewAnimationOptionCurveEaseInOut
    

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-04-13
      • 1970-01-01
      • 2011-07-31
      • 1970-01-01
      • 2014-10-04
      • 1970-01-01
      相关资源
      最近更新 更多