- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用以下函数从 View 生成图像
-(void)preparePhotos
{
[assetGroup enumerateAssetsUsingBlock:^(ALAsset *result, NSUInteger index, BOOL *stop)
{
if(result == nil)
{
return;
}
NSMutableDictionary *workingDictionary = [[NSMutableDictionary alloc] init];
UIImage *img = [[UIImage imageWithCGImage:[[result defaultRepresentation] fullResolutionImage]] resizedImageToSize:CGSizeMake(600, 600)];
[workingDictionary setObject:img forKey:@"UIImagePickerControllerOriginalImage"];
[appdelegate.arrImageData addObject:workingDictionary];
}];
}
但是随着调用该函数的次数增加,应用程序会崩溃。如何优化此函数或任何替代函数以从设备库获取图像,这不会导致像这样的 crash.function 调用。
[self performSelectorInBackground:@selector(preparePhotos) withObject:nil];
最佳答案
如果您想从照片库中获取所有图像,那么您应该只存储它们的资源 URL,而不是图像本身。假设您将 Assets url 存储在名为 photoAssets
的数组中,那么您可以通过仅传递索引来调用此方法:
- (UIImage *)photoAtIndex:(NSUInteger)index
{
ALAsset *photoAsset = self.photoAssets[index];
ALAssetRepresentation *assetRepresentation = [photoAsset defaultRepresentation];
UIImage *fullScreenImage = [UIImage imageWithCGImage:[assetRepresentation fullScreenImage]
scale:[assetRepresentation scale]
orientation:UIImageOrientationUp];
return fullScreenImage;
}
有关更多信息或引用,您应该引用 PhotoScroller和 MyImagePicker
关于ios - IOS 中应用程序每次都会因内存压力而崩溃?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21551580/
已关闭。此问题旨在寻求有关书籍、工具、软件库等的建议。不符合Stack Overflow guidelines .它目前不接受答案。 我们不允许提问寻求书籍、工具、软件库等的推荐。您可以编辑问题,以
我在 tomcat 服务器上部署了一个 Web 应用程序。我通过 POST 方法上传文件,然后上传文件被转码为另一种类型(例如 3gp 到 flv)。我如何测试,有多少并发上传和转码我的 Web 应用
我想知道是否有任何方法可以获取单击时的压力级别(用户单击鼠标键/按钮时产生的压力)。有资源或链接吗? 抱歉我的英语不好,希望我的问题很清楚,希望不仅仅是乌托邦! 最佳答案 我意识到我正在用一些当时不相
我写信是为了问一个关于 WCF 性能的问题。 1。背景 我们有一个在 .NET 3.5 上运行的客户端-服务器系统。服务器是 C# 服务,客户端是 silverlight 应用。 我写了一个压力测
我想编写一份包含 NMS 排序的报告。我想在报告中包含代码,但不包含运行压力。 我试过 message=FALSE, warning=FALSE, results='hide' 但它仍然包含在报告中。
我今天第一次尝试使用 cassandra-stress 工具。尽管我能够运行该工具,但输出中会显示很多“无法通过 JMX 连接;未收集这些统计信息”消息 命令 cassandra-stress use
关闭。这个问题需要多问focused 。目前不接受答案。 想要改进此问题吗?更新问题,使其仅关注一个问题 editing this post . 已关闭 9 年前。 Improve this ques
我希望通过一遍又一遍地不断访问网址列表来模拟网络服务器上的重负载! 最初,我计划使用 wget/curl 编写一个简单的脚本,但由于该站点使用大量 ajax 请求来完成大部分繁重的工作,因此这不是一个
我最近创建了一个回合制游戏服务器,可以接受数以万计的同时客户端连接(长话短说 - Linux 上的 epoll)。通信基于简单、自定义、基于线路的协议(protocol)。该服务器允许客户端连接、寻找
Stress-ng:我们可以使用stress-ng测试RAM吗?用于在 MIPS 32 设备上测试 RAM 的命令是什么? 最佳答案 在stress-ng中有许多基于内存的压力源: stress-ng
我正在 iPhone 上测试我的简单 OpenGL ES 实现(2D 游戏),并且在使用分析器时我注意到渲染利用率很高。这些是事实: 我以 60 fps 的速度仅显示一个预加载的大型纹理(512x51
我正在 canvas 上编写应该支持平板电脑和触摸压力的网络应用程序。不过,如果我没记错的话,我相信只有IE10支持这些指针事件。我想知道 chrome 和 firefox 是否会很快支持它? 最佳答
Stress-ng:如何使用 execv 在 C 或 Cpp 中编写应用程序来调用 stress-ng 命令以在 MIPS 中进行 CPU 和内存测试,并在成功或失败时返回其状态?给定一个可执行的 s
我是一名优秀的程序员,十分优秀!