Table View with Images, slow load and scroll

前端 未结 4 978
死守一世寂寞
死守一世寂寞 2020-12-12 06:55

I tried impletmenting about 30 tutorials today and just cant get anything to work.

My problem is that i load my information via a JSON file, add the data to a NSMuta

4条回答
  •  -上瘾入骨i
    2020-12-12 07:34

    You kinda left your problem wide open b/c you weren't specific enough. Performance issues can be related to a bunch of things. Here are a few performance things with tableview cells & images

    • Load images on a background thread.

    • Reuse cells - don't allocate any more than you need on screen

    static NSString *CellIdentifier = @"Cell";
    
        CellClass *cell = (CellClass*)[tv dequeueReusableCellWithIdentifier:CellIdentifier];
        if (cell == nil) cell = [[[CellClass alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
    

    • Only draw images that are the same size of the cell (ie. if a cell is 44 px high, keep UIimages at 44px). If images are bigger, you might have to process the images after downloading them from the internet.

    • Don't use uiimageview in your cell. instead create a custom cell (ie. subclass) and draw the image in your drawRect: function.

提交回复
热议问题