我有一个UIScrollview
UIView
,每个UIView
都有一个标签和图片。我正在循环这个视图,它工作正常,但是我有一个按钮Grid
,当我按下它时,它们变成了网格视图。问题是最后一项不能像其他项一样正常工作。其中一个标签隐藏在最后一项中。当我按下列表视图按钮时,最后一个项目再次出现问题,标签已完成,但“查看”没有更改。
-update。
内容大小没问题,它为最后一个项目留出了空间,但最后一个项目是某个地方。由于声誉,我无法发布图片。
` - (void)actionList {
int prods = 0;
isGrid = NO;
for(UIView*iView in sv_results.subviews){
for(UILabel *iView2 in iView.subviews){
if([iView2 isMemberOfClass:[UILabel class]]){
if(iView2.tag == 0)
{
iView2.frame = CGRectMake(80, 0, 150, 50);
iView2.font = [UIFont boldSystemFontOfSize:12.0f];
NSLog(@"%@",iView2.text);
}
else if(iView2.tag == 1)
{
pricewidth = [iView2.text sizeWithAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:13.0f]}];
iView2.frame = CGRectMake(80, 20, pricewidth.width+1, 50);
iView2.font = [UIFont systemFontOfSize:13.0f];
for(UIView *discountline in iView2.subviews)
{
discountline.frame = CGRectMake(0, iView2.frame.size.height/2, iView2.frame.size.width, 1);
}
}
else if(iView2.tag == 2)
{
iView2.frame = CGRectMake(screenRect.size.width-60, 30, 50, 15);
iView2.font = [UIFont systemFontOfSize:10.0f];
}
else if(iView2.tag == 3)
{
iView2.frame = CGRectMake(140, 20, 150, 50);
iView2.font = [UIFont systemFontOfSize:13.0f];
}
}
if([iView2 isMemberOfClass:[AsyncImageView class]]){
iView2.frame = CGRectMake(15,12,50,50);
iView2.layer.cornerRadius = 5;
}
}
NSLog(@"all avail data > %i",allAvailableData);
for(int i = 0;i<allAvailableData;i++)
{
if(iView.tag == i)
{
NSLog(@"UIView tag > %i",iView.tag);
iView.frame = CGRectMake(0,((i-1)*75),320,75);
}
}
prods++;
iView.layer.borderWidth = .3f;
}
NSLog(@"%i",prods);
sv_results.contentSize = CGSizeMake(320,(allAvailableData)*75);
}`