简体   繁体   中英

Objective c - Reload collection view async

I have a collection view with many pictures from Facebook.

It takes alot of time for the collection to load & show the pictures.

How can I show the pictures one by one without waiting for the end of the process?

This is my code:

-(void)viewDidAppear:(BOOL)animated
{
    NSMutableArray *jpegFiles = [[NSMutableArray alloc]init];

    NSMutableArray *picsArr =[[NSMutableArray alloc] initWithArray:[LocalUser sharedUser].profilePics];

    for(NSString *picLink in picsArr)
    {
        [jpegFiles addObject:[UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:picLink]]]];
        self.dataArray = jpegFiles;
        [self.collectionView reloadData];
    }
}

Look at SDWebImage . It'll handle all the asynchronous loading of the images from the web.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM