int totalCount = mvArray.count;//总条数
int pageCnt =6;//每一页填满的个数
int pageSize;//页数
int a = totalCount % pageCnt;//总数 % 行的个数 =余数 是否等于0判断是否换段
if (a ==0)
{
pageSize = totalCount / pageCnt;
}
else
{
pageSize = totalCount / pageCnt +1;
}
contentView.contentSize =CGSizeMake(300*pageSize,255);
pageControl.numberOfPages = pageSize;
for (int i =0; i
int pageTotal = pageCnt;
if (i==pageSize-1) {
pageTotal = totalCount - pageCnt*pageSize+pageCnt;
}
int rowCnt =3;//每行显示个数
int rowSize;//行数
int mol = pageTotal % rowCnt;//总数 % 行的个数 =余数 是否等于0判断是否换段
if (mol ==0)
{
rowSize = pageTotal / rowCnt;
}
else
{
rowSize = pageTotal / rowCnt +1;
}
for (int x=0; x
int clum;//几列
if (x == rowSize -1)
{
clum = pageTotal-x*rowCnt;//最后一行列数
}
else
{
clum = rowCnt;
}
for (int j=0; j< clum; j++) {
int _index = i*pageCnt+x*rowCnt+j;
NSString *path = [[mvArray objectAtIndex:_index]objectForKey:@"url"];
UIImageView *beautyVideoBtn = [[UIImageViewalloc] initWithFrame:CGRectMake(17*(j+1)+j*77+i*300,20+x*117,77, 77)];
[beautyVideoBtnsetImageWithURL:[NSURLURLWithString:path] placeholderImage:[UIImageimageNamed:@"default_pic.png"]];
beautyVideoBtn.layer.borderColor = [UIColorlightGrayColor].CGColor;
beautyVideoBtn.layer.borderWidth =0.5f;
beautyVideoBtn.tag = _index;
beautyVideoBtn.contentMode =UIViewContentModeScaleToFill;
[contentViewaddSubview:beautyVideoBtn];
beautyVideoBtn.userInteractionEnabled =YES;
UITapGestureRecognizer *tapGR = [[UITapGestureRecognizeralloc] initWithTarget:selfaction:@selector(clickVideoListEvent:)];
[beautyVideoBtnaddGestureRecognizer:tapGR];
[tapGRrelease];
[beautyVideoBtnrelease];
UILabel *titleLab = [[UILabelalloc] initWithFrame:CGRectMake(22*(j+1)+j*77+i*300,80+x*117,77, 77)];
titleLab.backgroundColor = [UIColorclearColor];
titleLab.text = [[mvArrayobjectAtIndex:_index] objectForKey:@"title"];
titleLab.textColor = [UIColorblackColor];
titleLab.font = [UIFontsystemFontOfSize:14.0f];
titleLab.numberOfLines =0;
[contentViewaddSubview:titleLab];
[titleLabrelease];
}
}
}
[videoViewaddSubview:contentView];
[contentView release];