2011-12-27 20 views

回答

0

如果我明白你的问题正确,这将帮助。这里Title2视图添加了动画,同时Title1.view被删除。你可以写类似的代码进行正确的过渡

-(void)handleLeftTransition:(id)sender 
{ 


    if(![self.view.subviews containsObject:title2.view]) 
    { 

    title2.view.frame = CGRectMake(320, 20, 320, 350); 
     [self.view addSubview:title2.view]; 

    [UIView animateWithDuration:0.5f 
        animations:^{ 
           title2.view.frame = CGRectMake(0, 20, 320, 350); 
         title1.view.frame = CGRectMake(-320, 20, 320, 350); 
        } 
        completion:^(BOOL finished){ 
         if([self.view.subviews containsObject:title1.view]) 
          [title1.view removeFromSuperview]; 
              }]; 
    } 


} 
4

@Hubert我已经做了一些调整,以你的代码,现在你可以滚动topScrollView和移动bottomScrollView继承人的代码

- (void)scrollViewDidScroll:(UIScrollView *)scrollView{ 
if (scrollView == self.bottomScrollView) { 
    //i dont know where this number came from 2.46153846 
    float bOffset = self.bottomScrollView.contentOffset.x/2.66666666666667; 
    NSLog(@"%f",self.bottomScrollView.contentOffset.x); 
    NSLog(@"%f",self.topScrollView.contentOffset.x); 
    CGPoint theOffset = CGPointMake(self.bottomScrollView.contentOffset.x, self.topScrollView.contentOffset.y); 
    theOffset.x = bOffset; 

    [self.topScrollView setContentOffset:theOffset animated:NO]; 
} 
// if the TopScrollView is Moved 
if (scrollView == self.topScrollView) { 
    float bOffset = self.topScrollView.contentOffset.x*2.66666666666667; 
    CGPoint theOffset = CGPointMake(self.topScrollView.contentOffset.x, self.bottomScrollView.contentOffset.y); 
    theOffset.x = bOffset; 

    [self.bottomScrollView setContentOffset:theOffset animated:NO]; 
} 

}

+0

不错。我将它添加到代码中。 – 2012-01-07 14:18:18

+0

@Alex 2.66666666666667是从哪里来的? – 2012-03-05 10:06:49

+0

ohh这是我的错误...如果我没有错...这是scrollview的大小划分的视图的大小或类似的东西...但它的错误...正确的数字是2.46153846 ...对不起关于那个 – Alex 2012-03-05 18:03:52