在 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];
}
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
UIImageView *imgView;
imgView=[[UIImageView 分配] initWithFrame:CGRectMake(tempX, tempY, 70, 70)];
温度X+=80;
if (tempX>300) {
}
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) {
}
UIImage * newImage = [[UIImage alloc] initWithData:imgDataToBeAdded];
[imgView setImage:newImage];
[self.view addSubview:imgView];
[imgView release];
}