Bonjours

J'ai une viewController avec une UIImageView qui prend la moitié de mon écran, sur l'action d'un bouton, mon image prend tout l'écran sans changer de view, j'aimerai rajouter la possibilité de faire des pinch zoom mais je n'y arrive pas !!! j'ai donc besoin d'aide de dev iOS qui envoi le pâté ^^

ma class,

MonZoomPerso.h

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
#import <Foundation/Foundation.h>
#import "TestZoomSurImage.h"
 
@interface MonZoomImage : NSObject <TestZoomSurImageDelegate>
 
+(void)zoomImage:(UIImageView*)monImageView;
 
 
@end
MonZoomPerso.m

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#import "MonZoomImage.h"
 
#define ZOOM_VIEW_TAG 100
#define ZOOM_STEP 1.5
 
 
static CGRect oldframe;
 
@implementation MonZoomImage
{
 
    NSInteger row;
    NSInteger col;
}
 
// Déclaration de notre méthode de classe
+(void)zoomImage:(UIImageView *)monImageView
{
 
    UIImage *image= monImageView.image;
    UIWindow *window=[UIApplication sharedApplication].keyWindow;
    UIView *backgroundView=[[UIView alloc]initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height)];
    oldframe=[monImageView convertRect:monImageView.bounds toView:window];
    backgroundView.backgroundColor=[UIColor clearColor];
    backgroundView.alpha=0;
    UIImageView *imageView=[[UIImageView alloc]initWithFrame:oldframe];
    imageView.image=image;
    imageView.tag=1;
    [backgroundView addSubview:imageView];
    [window addSubview:backgroundView];
 
    [imageView setTag:ZOOM_VIEW_TAG];
 
    UITapGestureRecognizer *tap=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(hideImage:)];
    [backgroundView addGestureRecognizer: tap];
 
 
 
    [UIView animateWithDuration:0.3 animations:^{
        imageView.frame=CGRectMake(0,([UIScreen mainScreen].bounds.size.height-image.size.height*[UIScreen mainScreen].bounds.size.width/image.size.width)/2, [UIScreen mainScreen].bounds.size.width, image.size.height*[UIScreen mainScreen].bounds.size.width/image.size.width);
        backgroundView.alpha=1;
    } completion:^(BOOL finished) {
 
    }];
}
 
+(void)hideImage:(UITapGestureRecognizer*)tap{
    UIView *backgroundView=tap.view;
    UIImageView *imageView=(UIImageView*)[tap.view viewWithTag:1];
    [UIView animateWithDuration:0.3 animations:^{
        imageView.frame=oldframe;
        backgroundView.alpha=0;
    } completion:^(BOOL finished) {
        [backgroundView removeFromSuperview];
    }];
}
 
 
@end
et mon bouton dans ma viewController

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
- (IBAction)zoom:(id)sender
{
 
    [MonZoomImage zoomImage:(UIImageView*)_imageView];
 
}
voila merci