0
我以NSDATA的形式在數組中創建了一些圖像,並且我一次在頁面控制器示例6的頁面上顯示它們。將NSDATA轉換爲UIImage時速度緩慢
但他們正在花時間獲得轉換爲UIImage這就是爲什麼滾動得到緩慢dowwn我們有任何其他選擇?
我正在使用下面的代碼將它們轉換成NSDATA。
[UImage imageWithData:data];
我以NSDATA的形式在數組中創建了一些圖像,並且我一次在頁面控制器示例6的頁面上顯示它們。將NSDATA轉換爲UIImage時速度緩慢
但他們正在花時間獲得轉換爲UIImage這就是爲什麼滾動得到緩慢dowwn我們有任何其他選擇?
我正在使用下面的代碼將它們轉換成NSDATA。
[UImage imageWithData:data];
在你的主線程:
NSOperationQueue *queue = [NSOperationQueue new];
NSInvocationOperation *operation = [[NSInvocationOperation alloc]
initWithTarget:self
selector:@selector(loadImage)
object:nil];
[queue addOperation:operation];
[operation release];
其他方法需要:
- (void)loadImage {
NSData* imageData = //however you're getting your NSData
UIImage* image = [[[UIImage alloc] initWithData:imageData] autorelease];
[imageData release];
[self performSelectorOnMainThread:@selector(displayImage:) withObject:image waitUntilDone:NO];
}
- (void)displayImage:(UIImage *)image {
[imageView setImage:image]; //UIImageView
}
@bdrase但仍然表現緩慢,因爲圖像的大小5 MB –
多大的圖像文件?如果它們不是很大,則可能表明存在另一個問題。如果是,那麼你應該嘗試在另一個線程中渲染。 – bdares
ARROUND 1 MB的一個IMAGE.how我可以開始他們的線程 –