我對這個cellForItemAtIndexPath:(NSIndexPath *)indexPath
更改圖片:
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
NSURL *imageURL = [NSURL URLWithString:[[Listname objectAtIndex:indexPath.item]coverURL]];
NSData *imageData = [NSData dataWithContentsOfURL:imageURL];
UIImage *image = [UIImage imageWithData:imageData];
dispatch_async(dispatch_get_main_queue(), ^{
shelfcell.bookCover.image = [UIImage imageWithData:imageData];
});
});
問題這一個shelfcell.bookCover.image
可以顯示圖像,但是當我使用
if (_checkversionfromBookPathF == 0.1){ shelfcell.bookCover.alpha = 0.5f;}
else if(_checkversionfromBookPathF == 1) { shelfcell.bookCover.alpha = 1.0f; }
圖像將只顯示_checkversionfromBookPathF == 1
但會首先顯示這一個_checkversionfromBookPathF == 0.1
然後_checkversionfromBookPathF == 1
爲什麼圖像不去shelfcell.bookCover.alpha = 0.5f;
請任何人解釋我。
你是saing alpha不適用於圖像?或它不會進入(如果塊)_checkversionfromBookPathF ==。1? – santhu
這將會'shelfcell.bookCover.alpha = 0.5f;'首先,但加載完成後它會像這樣'shelfcell.bookCover.alpha = 1.0f;' –
可能會有一些問題重複使用相同的單元格。由於您正在另一個線程中運行,因此在加載映像之前需要一段時間才能加載映像,因此此單元可能會重新用於執行shelfcell.bookCover.alpha = 1.0f的另一個indexPath。 – santhu