#import "KSPhotoBrowser.h"
for (int i = 0; i < self.imageUrlArray.count; i ++) {
UIImageView *picImageView = [[UIImageView alloc]initWithFrame:CGRectMake((DEVICE_SCREEN_WIDTH - 25 * 2 - 40) /3 * i + 10 * (i+1) , 0, (DEVICE_SCREEN_WIDTH - 25 * 2 - 40) /3, bottomView.height - 20)];
NSString *imageUrlString = [self.imageUrlArray[i] valueForKey:@"xlh"];
[picImageView sd_setImageWithURL:[NSURL URLWithString:imageUrlString] placeholderImage:DEFAULT_IMAGE_PLACEHOLDER];
picImageView.userInteractionEnabled = YES;
picImageView.tag = 1000+i;
[_livePictureScorllView addSubview:picImageView];
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(imageButtonClick:)];
tap.numberOfTapsRequired = 1;
tap.numberOfTouchesRequired = 1;
[picImageView addGestureRecognizer:tap];
}
//看图片
- (void)imageButtonClick:(UITapGestureRecognizer *)tap
{
NSMutableArray *items = [[NSMutableArray alloc]init];
for (int i = 0; i < self.imageUrlArray.count; i++)
{
UIImageView *imageView = [_livePictureScorllView viewWithTag:1000+i];
KSPhotoItem *item = [KSPhotoItem itemWithSourceView:imageView imageUrl:[NSURL URLWithString:[self.imageUrlArray[i] valueForKey:@"xlh"]]];
[items addObject:item];
}
KSPhotoBrowser *browser = [KSPhotoBrowser browserWithPhotoItems:items selectedIndex:tap.view.tag-1000];
// browser.noSingleTap = YES;
// browser.noSingleTap = NO;
browser.dismissalStyle = KSPhotoBrowserInteractiveDismissalStyleScale;
browser.pageindicatorStyle = KSPhotoBrowserPageIndicatorStyleText;
browser.backgroundStyle = KSPhotoBrowserBackgroundStyleBlack;
[browser showFromViewController:self];
}
网友评论