在iPhone上显示多个图像缩略图时UI失真



我想在视图上显示缩略图。我正在使用以下方法将图像添加到缩略图中。图像取自数据库

当我添加一个图像时,一切都很好。但是,如果我在循环中调用这个方法来添加多个图像,就会发生奇怪的事情(UI失真,屏幕的某些部分变黑,不仅对于这个应用程序,甚至对于主屏幕)

在模拟器上,即使我添加了很多图像,一切都很好。

有人知道我哪里错了吗?我是不是错过了什么?

-(void)addImageThumbnailOnViewWithImageData:(NSData *)imgDataToBeAdded{
    UIImageView *imgView;
    imgView=[[UIImageView alloc] initWithFrame:CGRectMake(tempX, tempY, 70, 70)];
    tempX+=80;
    if (tempX>300) {
        tempX=10;
        tempY+=80;
    }
    UIImage * newImage = [[UIImage alloc] initWithData:imgDataToBeAdded];
    [imgView setImage:newImage];
    [self.view addSubview:imgView]; 

    [imgView release];
}

UIImageView*imgView;

imgView=[[UIImageView alloc]initWithFrame:CGRectMake(tempX,tempY,70,70)];

tempX+=80;如果(tempX>300){

tempX=10;
tempY-=80;//i think u have to modify this with -

}

UIImage*newImage=[[UIImage alloc]initWithData:imgDataToBeAdded];

[imgView setImage:newImage];

[self.view addSubview:imgView];

[imgView发布];

}

最新更新