J'ai des images dans mon UIScrollview qui est ajouté dans View.
plz passer par mon code-
Détecter le contact dans UIImageView dans UIScrollView
@interface ScrollViewController : UIScrollView <UIScrollViewDelegate>{
UIImageView *productImage;
UILabel *productName;
NSArray *productArray;
}
@property(nonatomic,retain) UIImageView *productImage;
@property(nonatomic,retain) UILabel *productName;
@property(nonatomic,retain) NSArray *productArray;
- (id)initWitProducts:(NSArray*)_data;
*.m*
- (id)initWitProducts:(NSArray *)_data
if ((self = [super init])){
productArray=[[NSArray alloc]initWithArray:_data];
[self setFrame:CGRectMake(0, 0, 320, 480)];
int countList=[self.productArray count];
self.contentSize=CGSizeMake(320, 585);
for(int i=0;i<countList;i++)
{
productImage=[[UIImageView alloc]initWithImage:[UIImage imageNamed:[[productArray objectAtIndex:i]objectForKey:@"ProductImage"]]];
productImage.frame=CGRectMake(95, 35+i*125, 100, 100);
[productImage setUserInteractionEnabled:YES];
[self addSubview:productImage];
}
return self;
}
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent*)event
{
if([[touches anyObject]view]==self.productImage)
NSlog(@"Image Touched");
}
Cela fonctionne bien, mais seulement pour la dernière image en Array
le touchesBegan ne fonctionne pas pour d'autres images en Array
Que dois-je ajouter ici pour détecter le contact sur toutes les images (1er, 2ème, ... etc) de Array
sorry..but i did't obtenu votre idée. – user440485
pouvez-vous mettre à jour mon code .... plz ?? – user440485