内存管理

发布于 2024-09-13 21:02:43 字数 626 浏览 1 评论 0原文

我需要大家澄清一下,那就是我正在实现一个iPad应用程序。我尝试下载图像并制作动画。图像数量应该超过100,000。我用来下载并添加到视图的代码如下。

UIImageView* imageView=[[UIImageView alloc]initWithFrame:CGRectMake(0, 0,100,100)];
NSData *receivedData=nil;
receivedData = [NSData dataWithContentsOfURL:[NSURL URLWithString:@"http://path/prudently/iphone/image_s/e545afbf-4e3e-442e-92f9-a7891fc3ea9f/test.png"]];
imageView.image = [[UIImage alloc] initWithData:receivedData] ;
[subView addSubview:imageView];
[imageView release];

但是在我成功地将 8000 多个图像添加到我的子视图后,我遇到了异常。我从 url 获取数据时遇到异常。还有一件事我不会发布子视图,因为一旦我下载了它们,我需要为子视图设置动画。

请给我您的建议

谢谢, 塞卡尔·贝塔拉姆。

I need a clarification from all of you,That is I am implementing an iPad application. In that I tried to download and animate the images. The image count should be more than 100,000.The code I used to download and adding to the view is as follows.

UIImageView* imageView=[[UIImageView alloc]initWithFrame:CGRectMake(0, 0,100,100)];
NSData *receivedData=nil;
receivedData = [NSData dataWithContentsOfURL:[NSURL URLWithString:@"http://path/prudently/iphone/image_s/e545afbf-4e3e-442e-92f9-a7891fc3ea9f/test.png"]];
imageView.image = [[UIImage alloc] initWithData:receivedData] ;
[subView addSubview:imageView];
[imageView release];

But I am getting exception after I successfully added more than 8000 image to my subview. I am getting exception at getting data from the url. And one more thing I am not releasing the subview because once I downloaded them I need to animate the subview.

Please give me your suggessions

Thank you,
Sekhar Bethalam.

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

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

发布评论

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

评论(3

断爱 2024-09-20 21:02:43

对于桌面应用程序来说,100,000 张图像似乎很多,更不用说像 iPhone 这样的智能手机了。是否没有其他方法可以解决这个问题,并且不需要如此高的资源数量?

100,000 images would seem a lot for desktop applications, let alone a smart phone like an iPhone. Is there not another approach you can take to solve this problem that wouldn't need such a high resource count?

沩ん囻菔务 2024-09-20 21:02:43

您可以将 URL、图像或其他内容写入缓存文件,然后划分一些页面以对图像进行动画处理...
当用户按下页面链接时,应用程序读取该页面的图像并为其设置动画,用户不使用的页面图像不需要显示。

You can write the URL , images or something to a cached file, and divide some pages to animate the images...
When the user press a page link , application read and animate the images of this page, images of the page which user don't use need not display.

情归归情 2024-09-20 21:02:43

实现此目的的唯一方法是根据屏幕上的需要动态创建和销毁 UIImageView。由于设备上的可用内存有限,iPhone/iPad/iAnything 无法执行您想要的操作。

The only way you are going to accomplish this is to dynamically create and destroy the UIImageViews as they are needed on the screen. The iPhone/iPad/iAnything are incapable of doing what you want because of the limited memory available on the device.

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