0
我有iCloud上的圖像和我subclassed UIDocument他們。現在我想在ViewController加載後在UITableView上顯示圖像。因此,我增加這個代碼viewDidLoad
方法內加載文件從iCloud視圖之前將被加載
- (void)viewDidLoad
{
...
iCloudImage *iClImage = [[iCloudImage alloc] initWithFileURL:ubiquitousPackage];
[iClImage openWithCompletionHandler:^(BOOL success) {
if (success) {
NSLog(@"iCloud document opened");
dataFromFileManager = [iClImage.imageDictionary objectForKey:img.fileName];
imageToDraw = [[[UIImage alloc] initWithData:dataFromFileManager] autorelease];
} else {
NSLog(@"failed opening document from iCloud");
imageToDraw = [UIImage imageNamed:@"defaultImage.jpg"];
}
[arrayOfImages addObject:imageToDraw];
}];
...
}
在這裏,我收集所有圖像一個接一個成NSMutableArray *arrayOfImages
,然後使用在- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
方法數組。 但他們沒有在表中顯示,因爲他們正在下載另一個線程。 如何解決這個問題,並開始只顯示圖像下載或默認圖像設置後顯示UITableView?