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

发布于 2024-11-16 03:18:41 字数 664 浏览 4 评论 0原文

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

当我添加单个图像时,一切正常。但是,如果我循环调用此方法来添加多个图像,则会发生奇怪的事情(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];

}

I want to display thumbnail images on a view.
I am using following method to add an image to thumbnails. Images are taken from the database

When I add a single image, everything works fine. But if I call this method in a loop to add multiple images, strange things happen (UI gets distorted and some part of screen goes black, not only for this application even for home screen)

On the simulator, everything works fine even if I add many images.

Does anyone have any idea, where I am going wrong? am I missing out something?

-(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];

}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

山川志 2024-11-23 03:18:41

UIImageView *imgView;

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

温度X+=80;
if (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发布];

}

UIImageView *imgView;

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

tempX+=80;
if (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 release];

}

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文