2017年4月15日
一.UITapGestureRecognizer点击手势(点击控件,获得动作)
1.实现
for (int i=0,j=0; i<[resultArray count]; i++) {
UIImage *image = [UIImage imageWithContentsOfFile:[NSString stringWithFormat:@"%@/%@",self.file,resultArray[i]]];
if(image)
{
[self.pictureArray addObject:image];
UIImageView *imageView=[[UIImageView alloc] initWithImage:image];
imageView.tag = j + tag_begin_index;
[imageView setFrame:CGRectMake(0,i*HHBHEIGHT/2.5, HHBWIDTH, imageHeight)];
imageView.userInteractionEnabled = YES;
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(pictureBrowse:)];
[imageView addGestureRecognizer:tap];
[self.scrollView addSubview:imageView];
[self.scrollView setContentSize:CGSizeMake(HHBWIDTH,imageView.frame.origin.y + imageHeight + 10)];
j++;
}
}
- (void)pictureBrowse:(UIGestureRecognizer *)recognizer{
HuPictureBrowser * broser = [[HuPictureBrowser alloc] init];
UIImageView *view = (UIImageView *)[recognizer view];
NSInteger i = view.tag - tag_begin_index;
if(i < _pictureArray.count){
broser.pictureImage = self.pictureArray[i];
[self.navigationController presentViewController:broser animated:YES completion:nil];
}
}
如果您发现本文对你有所帮助,如果您认为其他人也可能受益,请把它分享出去。