2011-12-27 47 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