2014-02-13 69 views
0

我有一個scrollview包含2個圖像視圖只在一個頁面中。我縮放滾動視圖,以覆蓋竊聽全屏。現在我想縮放後,應啓用分頁。但它然後跳過每個備用圖像視圖。任何幫助將appreciated.`縮放後調整大小uiscrollview,以啓用分頁

kNumViews = 10; 
vScrollObjectHeight = 230; // half screen 
vScrollObjectWidth = 160; // half screen 
{ 
for (i = 1; i <= kNumViews; i++) 
{ 


    NSString *imageName = [NSString stringWithFormat:@"imageV%d.jpg", i]; 
    UIImage *image = [UIImage imageNamed:imageName]; 
    UIImageView *imageView = [[UIImageView alloc] initWithImage:image]; 
    [imageView sizeToFit]; 
    imageView.layer.borderColor = [UIColor grayColor].CGColor; 
    imageView.layer.borderWidth = 1.5f; 

    CGRect rect = imageView.frame; 
    rect.size.height = vScrollObjHeight; 
    rect.size.width = vScrollObjWidth; 
    imageView.frame = rect; 
    imageView.tag = i; 

    imageView.userInteractionEnabled = YES; 
    [scrollView2 addSubview:imageView]; 

} 
[self layoutScrollViews]; 
self.swipeRecognizerUp = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(scaleMove:)]; 
[self.swipeRecognizerUp setDelegate:self]; 
[scrollView2 addGestureRecognizer:self.swipeRecognizerUp]; 

self.swipeRecognizerDown = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(scaleDown:)]; 
[self.swipeRecognizerDown setDelegate:self]; 
[scrollView2 addGestureRecognizer:self.swipeRecognizerDown]; 
self.swipeRecognizerDown.enabled = NO; 

} 


-(void)scaleMove:(id)sender { 

    [[[(UIPanGestureRecognizer*)sender view] layer] removeAllAnimations]; 
    [self.view bringSubviewToFront:[sender view]]; 

    CGPoint velocity = [sender velocityInView:self.view]; 
    if(abs(velocity.y) - abs(velocity.x) > 500 && velocity.y < 0){ 
    [sender view].transform = CGAffineTransformMakeScale(1.0, 1.0); 
    //[sender view].transform = CGAffineTransformMakeTranslation(0, 230); 

    [UIView animateWithDuration:0.5 
        animations:^(){ 
         CGAffineTransform scale = CGAffineTransformMakeScale(2.0, 2.0); 
         CGAffineTransform translate = CGAffineTransformMakeTranslation(0,-230); 
         [sender view].transform = CGAffineTransformConcat(translate, scale); 
         //NSLog(@"%f %f",[sender view].frame.size.width,[sender view].frame.size.height); 
         scrollView2.pagingEnabled = YES; 




        } 
        completion:nil]; 
    self.swipeRecognizerDown.enabled = YES; 
    self.swipeRecognizerUp.enabled = NO; 
    } 

} 

} 
` 
+0

分享你的代碼? – Retro

+0

@Retro我已經分享了代碼。請看看它。 – protocolon

回答

0

發現了它的答案......我已經設置滾動型一半的寬度,然後子類滾動視圖,以便覆蓋pointInside再正常縮放它scrollview.found答案。 ..我已經設置了一半的滾動視圖的寬度,然後子類的滾動視圖,以覆蓋pointInside,然後通常縮放滾動視圖。

相關問題