Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/41.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/28.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 在目标c中收缩放大和缩小_Iphone_Objective C_Cocoa_Pinchzoom - Fatal编程技术网

Iphone 在目标c中收缩放大和缩小

Iphone 在目标c中收缩放大和缩小,iphone,objective-c,cocoa,pinchzoom,Iphone,Objective C,Cocoa,Pinchzoom,如何在我们的应用程序中集成收缩缩放,我正在使用scrollView上的imageview 我的代码是: - (IBAction)handlePinchGesture:(UIGestureRecognizer *) recognizer { if(zoomEnable == TRUE) { CGFloat factor = [(UIPinchGestureRecognizer *) recognizer scale]; CGFloat lastSc

如何在我们的应用程序中集成收缩缩放,我正在使用scrollView上的imageview 我的代码是:

- (IBAction)handlePinchGesture:(UIGestureRecognizer *) recognizer {
    if(zoomEnable == TRUE)
    {

        CGFloat factor = [(UIPinchGestureRecognizer *) recognizer scale];
        CGFloat lastScaleFactor = 1;

        //if the current factor is greater 1 --> zoom in
        if (factor > 1) {
            scrollView.transform = CGAffineTransformMakeScale(lastScaleFactor + (factor-1),lastScaleFactor + (factor-1));
            scrollView.scrollEnabled = YES;

        } else {

            [UIView beginAnimations:@"animation" context:nil];
            [UIView setAnimationDuration:0.5];
            [UIView setAnimationTransition:UIViewAnimationTransitionNone forView:scrollView cache:NO];
            scrollView.transform = CGAffineTransformMakeScale(1,1);     
            [UIView commitAnimations];

        }
        isScrollable = TRUE;
    }

}
它开始缩放每次从开始我想如果我缩放一些,然后再次开始,当我停止缩放。非常感谢您的帮助


谢谢,

如果您已经在使用
UIScrollView
,则不需要使用
UIgestureRecognitors
UIScrollView
支持按比例缩放


要使缩放和平移工作正常,学员必须同时实现
viewForZoomingInScrollView:
scrollViewDidEndZooming:withView:atScale:
;此外,最大(
maximumZoomScale
)和最小(
minimumZoomScale
)缩放比例必须不同。

如果您已经在使用
UIScrollView
,则无需使用
UIgestureRecognitors
UIScrollView
支持按比例缩放

-(void)zoomingImages{ 
    self.FullSizeScrollView.pagingEnabled =YES;
    NSMutableArray *_scrollArray =[[NSMutableArray alloc]init];

    // add images to scroll array

        [_scrollArray addObject:self.image1];
        [_scrollArray addObject:self.image2];

    //now call init with frame function given below to set frame for each image in scroll view
    for(int i =0 ;i<[_scrollArray count];i++){
        ZoomingImageView *_imageScrollView = [[ZoomingImageView alloc]initWithFrame:CGRectMake(i*320, 0, 320, 460)];
        _imageScrollView.captureView=self;      
        [self.checkFullSizeScrollView addSubview:_imageScrollView];
        [_imageScrollView release];
        self.checkFullSizeScrollView.contentSize = CGSizeMake((i*320)+320, 460);
    }

    [_scrollArray release];
}


@implementation ZoomingImageView

- (id)initWithFrame:(CGRect)frame{

    self = [super initWithFrame:frame];

      if (self) {

        self.maximumZoomScale = 4;
        self.minimumZoomScale = 1;     
        self.userInteractionEnabled = YES;
        self.multipleTouchEnabled = YES;
        self.delegate = self;
        self.bouncesZoom = NO;
        self.currentImageView.clipsToBounds=NO;
        self.contentMode =UIViewContentModeScaleAspectFit;
        UIImageView *zoomImageView_ =[[UIImageView alloc]initWithFrame:CGRectMake(0, 0, frame.size.width, frame.size.height)];
        self.currentImageView = zoomImageView_;
        [zoomImageView_ release];
         self.currentImageView.contentMode =UIViewContentModeScaleAspectFit;
        self.currentImageView.userInteractionEnabled = YES;
        self.currentImageView.multipleTouchEnabled = YES;
        [self addSubview:self.currentImageView];}
return self;}
要使缩放和平移工作正常,学员必须同时实现
viewForZoomingInScrollView:
scrollViewDidEndZooming:withView:atScale:
;此外,最大(
maximumZoomScale
)和最小(
minimumZoomScale
)缩放比例必须不同。

-(无效)缩放图像{
-(void)zoomingImages{ 
    self.FullSizeScrollView.pagingEnabled =YES;
    NSMutableArray *_scrollArray =[[NSMutableArray alloc]init];

    // add images to scroll array

        [_scrollArray addObject:self.image1];
        [_scrollArray addObject:self.image2];

    //now call init with frame function given below to set frame for each image in scroll view
    for(int i =0 ;i<[_scrollArray count];i++){
        ZoomingImageView *_imageScrollView = [[ZoomingImageView alloc]initWithFrame:CGRectMake(i*320, 0, 320, 460)];
        _imageScrollView.captureView=self;      
        [self.checkFullSizeScrollView addSubview:_imageScrollView];
        [_imageScrollView release];
        self.checkFullSizeScrollView.contentSize = CGSizeMake((i*320)+320, 460);
    }

    [_scrollArray release];
}


@implementation ZoomingImageView

- (id)initWithFrame:(CGRect)frame{

    self = [super initWithFrame:frame];

      if (self) {

        self.maximumZoomScale = 4;
        self.minimumZoomScale = 1;     
        self.userInteractionEnabled = YES;
        self.multipleTouchEnabled = YES;
        self.delegate = self;
        self.bouncesZoom = NO;
        self.currentImageView.clipsToBounds=NO;
        self.contentMode =UIViewContentModeScaleAspectFit;
        UIImageView *zoomImageView_ =[[UIImageView alloc]initWithFrame:CGRectMake(0, 0, frame.size.width, frame.size.height)];
        self.currentImageView = zoomImageView_;
        [zoomImageView_ release];
         self.currentImageView.contentMode =UIViewContentModeScaleAspectFit;
        self.currentImageView.userInteractionEnabled = YES;
        self.currentImageView.multipleTouchEnabled = YES;
        [self addSubview:self.currentImageView];}
return self;}
self.FullSizeScrollView.PaginEnabled=是; NSMutableArray*_scrollArray=[[NSMutableArray alloc]init]; //将图像添加到滚动阵列 [\u scrollArray addObject:self.image1]; [\u scrollArray addObject:self.image2]; //现在使用下面给出的frame函数调用init,为滚动视图中的每个图像设置帧 对于(int i=0;i
-(void)缩放图像{
self.FullSizeScrollView.PaginEnabled=是;
NSMutableArray*_scrollArray=[[NSMutableArray alloc]init];
//将图像添加到滚动阵列
[\u scrollArray addObject:self.image1];
[\u scrollArray addObject:self.image2];
//现在使用下面给出的frame函数调用init,为滚动视图中的每个图像设置帧

对于(int i=0;i支持快速翻转。我使用的是scrollview,但当我返回缩放中的任何对象时,我有三个图像对象current、prev和next。将其缩放为多个图像。你是否尝试实现像照片应用程序中那样的图像浏览器?在何处滑动以查看下一个图像?完全正确..我正在尝试与照片应用程序相同..知道吗?Don“不要重新发明轮子。这项功能在web上有几种实现方式。只需搜索即可。例如:WWDC 2010中有一个类介绍了如何实现iPhoto风格的照片浏览器。从2012年开始,有一个类显示无限滚动。2011年也不错。您可以通过develop.apple.com访问视频(需要会员资格)。感谢您的快速回复。我正在使用scrollview,但当我返回缩放中的任何对象时,我有三个图像对象current、prev和next代表其已缩放的多个图像。您是否尝试在照片应用程序中实现类似的图像浏览器?您在何处滑动以查看下一个图像?完全正确。我正在尝试与照片应用程序相同的操作。有任何想法。不要重新发明轮子。这个功能在网络上有几种实现方式。只需搜索即可。例如:WWDC 2010中有一个类,它描述了如何实现iPhoto风格的照片浏览器。从2012年开始,有一个类显示无限滚动。2011年也不错。你可以通过develop.apple.com访问视频(需要会员资格)。