久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

在滾動視圖內的 UIImageView 上捏縮放效果?

Pinch To Zoom Effect on UIImageView inside scrollView?(在滾動視圖內的 UIImageView 上捏縮放效果?)
本文介紹了在滾動視圖內的 UIImageView 上捏縮放效果?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我正在使用情節提要 (iOS 6.0) 為我的應用創建照片庫查看器.這就是我的 imageViewController 在情節提要中的設置方式:

I'm using storyboard (iOS 6.0) to create a photo gallery viewer for my app. This is how my imageViewController is set up in storyboard:

我已確保在 imageView 和 scrollView 上啟用 userInteraction 和多次觸摸.我想要做的是,在捏我想放大 imageView(最大比例 3)并能夠平移.這是我目前擁有的,但是,即使檢測到捏合手勢,比例也不會改變.

I've made sure to enable userInteraction and multiple touches on both the imageView and scrollView. What I want to do is, on pinch I want to zoom into the imageView (maximum scale 3) and be able to pan around. This is what I currently have, however, even though the pinch gesture is detected the scale does not change.

- (IBAction)imagePinched:(id)sender {

if (pinchRecognizer.state == UIGestureRecognizerStateEnded || pinchRecognizer.state == UIGestureRecognizerStateChanged) {

    NSLog(@"gesture.scale = %f", pinchRecognizer.scale);

    CGFloat currentScale = self.fullScreenView.frame.size.width / self.fullScreenView.bounds.size.width;
    CGFloat newScale = currentScale * pinchRecognizer.scale;

    if (newScale < 1) {
        newScale = 1;
    }
    if (newScale > 3) {
        newScale = 3;
    }

    CGAffineTransform transform = CGAffineTransformMakeScale(newScale, newScale);
        self.fullScreenView.transform = transform;
        pinchRecognizer.scale = 1;
    }

}

大多數在線問題和教程都涉及以編程方式創建視圖并執行此操作,但代碼越少越好(在我看來).讓它與故事板一起使用的最佳方法是什么?提前謝謝!!!

Most questions and tutorials online deal with programmatically creating the views and doing this, but the less code the better (in my eyes). What's the best way to get this to work with storyboard? Thank you in advance!!!

更新:

這是我完整的 .m 文件代碼:

Here is my full .m file code:

- (void)viewDidLoad
{
    [super viewDidLoad];

    //Assign an image to this controller's imageView
    fullScreenView.image = [UIImage imageNamed:imageString];

    //Allows single and double tap to work
    [singleTapRecognizer requireGestureRecognizerToFail: doubleTapRecognizer];
}

- (IBAction)imageTapped:(id)sender {

    NSLog(@"Image Tapped.");

    //On tap, fade out viewController like the twitter.app
    [self dismissViewControllerAnimated:YES completion:nil];
}

- (IBAction)imageDoubleTapped:(id)sender {

    NSLog(@"Image Double Tapped.");

    //On double tap zoom into imageView to fill in the screen.
    [fullScreenView setContentMode:UIViewContentModeScaleAspectFill];
}

- (IBAction)imagePinched:(id)sender {

    if (pinchRecognizer.state == UIGestureRecognizerStateEnded || pinchRecognizer.state == UIGestureRecognizerStateChanged) {

        NSLog(@"gesture.scale = %f", pinchRecognizer.scale);

        CGFloat currentScale = self.fullScreenView.frame.size.width / self.fullScreenView.bounds.size.width;
        CGFloat newScale = currentScale * pinchRecognizer.scale;

        if (newScale < 1) {
            newScale = 1;
        }
        if (newScale > 3) {
            newScale = 3;
        }

        CGAffineTransform transform = CGAffineTransformMakeScale(newScale, newScale);
        self.fullScreenView.transform = transform;
        pinchRecognizer.scale = 1;
    }
}

- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView
{
    return self.fullScreenView;
}


-(void)scrollViewDidEndZooming:(UIScrollView *)scrollView withView:(UIView *)view atScale:(float)scale {

}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end

推薦答案

我認為 Apple 文檔中有更好的解決方案

I think better solution in Apple Documentation

- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView

{

    return self.imageView;

}
- (void)viewDidLoad {

    [super viewDidLoad];

    self.scrollView.minimumZoomScale=0.5;

    self.scrollView.maximumZoomScale=6.0;

    self.scrollView.contentSize=CGSizeMake(1280, 960);

    self.scrollView.delegate=self;

}

查看 Apple 文檔

這篇關于在滾動視圖內的 UIImageView 上捏縮放效果?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

iOS - Using storyboard and autolayout to center the UIScrollView(iOS - 使用故事板和自動布局使 UIScrollView 居中)
get index or tag value from imageview tap gesture(從 imageview 點擊手勢獲取索引或標簽值)
UIScrollView not scrolling regardless of large contentSize(無論內容大小如何,UIScrollView 都不會滾動)
Clean autorotation transitions in a paging UIScrollView(清除分頁 UIScrollView 中的自動旋轉轉換)
UIScrollView zooming with Auto Layout(UIScrollView 使用自動布局縮放)
How to create an image from a UIView / UIScrollView(如何從 UIView/UIScrollView 創建圖像)
主站蜘蛛池模板: 亚洲成人一区 | 草逼网站 | 在线观看久草 | 高清久久 | 国产成人精品久久二区二区91 | 日韩免费激情视频 | 免费在线视频精品 | 羞羞色在线观看 | 在线不卡av| 日韩精品无码一区二区三区 | 91亚洲国产成人久久精品网站 | 日本亚洲欧美 | 99亚洲 | 99av成人精品国语自产拍 | 91精品国产综合久久久久久丝袜 | 国产成人精品一区二区三区在线 | 日本a视频 | 美女视频网站久久 | 精品久久影院 | 日韩在线国产 | 欧美一级久久 | 亚洲精品一区中文字幕乱码 | 欧美日韩国产高清视频 | 国产99免费 | 久视频在线观看 | 69精品久久久久久 | 免费午夜电影 | 亚洲精品福利视频 | 在线观看一区 | 久久精品日 | 亚洲国产aⅴ成人精品无吗 亚洲精品久久久一区二区三区 | 国产精品福利在线观看 | 午夜影视免费片在线观看 | 亚洲区视频 | 成人在线观 | 亚洲一区二区高清 | 精品视频亚洲 | 91精品国产综合久久久动漫日韩 | 国产精品久久久久久久久久不蜜臀 | 日屁视频 | 欧美日韩国产在线观看 |