NSOperation mainQueue 问题 [英] NSOperation mainQueue issue

查看:64
本文介绍了NSOperation mainQueue 问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有幻灯片,我想显示大图,我在[NSOperation mainQueue]操作中加入了低优先级,这个操作显示了图像.

I have slideshow, and I want to show Big images, I added to [NSOperation mainQueue] operation with low priority, this operation shows the image.

如果图像很小,一切正常,但是当图像大约为 5Mb 时,视图会冻结 1 秒,并且我无法滚动幻灯片.我认为,对于 iPhone 来说,显示大图像太难了,主队列太过载了.

If image is small , everything is OK, but when image is about 5Mb, the view freeze for 1 second, and I can't scroll my slideshow. I think, that displaying big images just so difficult for iPhone, that main queue is too overloaded.

但我不明白,因为我所有的显示代码都是在低优先级操作中执行的.

But I don't inderstand it , because all my displaying code is executed in low priority operation.

这是显示代码.

[imageView removeFromSuperview];
imageView = nil;

// reset our zoomScale to 1.0 before doing any further calculations
self.zoomScale = 1.0;

// make a new UIImageView for the new image
self.imageView = [[[UIImageView alloc] initWithImage:image] autorelease];
[self addSubview:imageView];

self.contentSize = [image size];
[self setMaxMinZoomScalesForCurrentBounds];
self.zoomScale = self.minimumZoomScale;

我可以设置手势识别器的优先级吗(UIScrollView 的常规任务识别器?)

May be I can set the priority for gesture recognizers (the regular questure recognizers for UIScrollView?)

更新

请看我的新话题,我更恰当地描述了这个问题我的话题

Please look at my new topic, I described the issue more properly my topik

推荐答案

优先级与日程安排有关.如果您在 runloop 迭代期间将一堆操作排队,那么它们将按其在该队列上的优先级执行.

Priority has to do with scheduling. If you queue up a bunch of operations during a runloop iteration then they will be executed by their priority on that queue.

加快速度的一种解决方案是包含缩放到显示它们的确切大小的资源.如果您尝试在 200x200 区域中显示 2000x2000 像素的图像,则系统会缩放所有这些记忆中的东西.您还可以以编程方式动态创建更小以适应图像.这可以在后台队列中完成,这样您的 UI 仍然可以响应.

One solution to speed this up would be to either include resources that are scaled to the exact size that you are displaying them in. If you are trying to show a 2000x2000 px image in a 200x200 area then the system to scale all this stuff in memory. You can also dynamically create smaller to fit images programmatically. This can be done on a background queue so your UI is still responsive.

如何在iphone中的objective-c

这篇关于NSOperation mainQueue 问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆