I have seen an app called ZuluTrade, which has a charts in there tableView cells.
Basically it seems to be images in tableViewCell’s imageView.
When the page loads the tableView displays the text first and then it loads the images into the tableViewCell as we scroll through the tableView.
This helps to improve the performance because the user does not have to wait till all things are loaded into the cell and also it makes tableView scrolling smooth.
How can that feature be achieved?
Here are the screenshots of the app:


Code in my tableView cellForRowAtIndexPath:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
NSString *MyIdentifier = [NSString stringWithFormat:@"MyIdentifier %i", indexPath.row];
MyTableCell *cell = (MyTableCell *)[tableView dequeueReusableCellWithIdentifier:MyIdentifier];
//if (cell == nil) {
cell = [[[MyTableCell alloc] initWithFrame:CGRectZero reuseIdentifier:MyIdentifier] autorelease];
NSString *testVal = [[NSUserDefaults alloc] valueForKey:@"idValue"];
if (testVal == (NSString *)[NSNull null]) {
testVal = @"NULL";
}
//NSLog(@"testVal : %@",testVal);
NSLog(@"Fund Name : %@",[[array1 objectAtIndex:indexPath.row] valueForKey:@"FundName"]);
NSDate *date = [NSDate date];
NSDateFormatter *dtFormat = [[NSDateFormatter alloc] init];
[dtFormat setDateFormat:@"yyyy-MM-dd"];
NSString *dtString = [dtFormat stringFromDate:date];
NSString *fundname = [NSString stringWithFormat:@"%@",[[array1 objectAtIndex:indexPath.row] valueForKey:@"FundName"]];
NSString *imageName =[NSString stringWithFormat:@"%@_%@.png",fundname,dtString];
//NSFileManager *fileManager = [NSFileManager defaultManager];
NSString *documentsDirectory = [self getImagePath];
NSLog(@"Image Path : %@",documentsDirectory);
NSError *error1;
NSString *filepath1;
NSArray *files = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:documentsDirectory error:&error1];
if (files == nil) {
NSLog(@"Error reading contents of documents directory: %@", [error1 localizedDescription]);
}
NSLog(@"FileName: %@",imageName);
BOOL success = NO;
for (NSString *file in files)
{
NSLog(@"file in Files is %@",file);
if([file isEqualToString:[NSString stringWithFormat:@"%@",imageName]])
{
filepath1 = [documentsDirectory stringByAppendingPathComponent:file];
NSLog(@"Full Path :%@",filepath1);
success = YES;
}
}
if(success == YES)
{
cell.imageView.image = [UIImage imageWithContentsOfFile:filepath1];
}
else if(success != YES)
{
cell.imageView.image = [UIImage imageNamed:@"newfund.png"];
}
UILabel *label = [[[UILabel alloc] initWithFrame:CGRectMake(60.0, 0, 120.0,
tableView.rowHeight)] autorelease];
[cell addColumn:50];
label.textColor = [UIColor blackColor];
label.tag = LABEL_TAG;
label.font = [UIFont systemFontOfSize:12.0];
//NSLog(@"%@",[[array1 objectAtIndex:indexPath.row] valueForKey:@"FundName"]);
label.text = [NSString stringWithFormat:@"%@",[[array1 objectAtIndex:indexPath.row] valueForKey:@"FundName"]];
//NSLog(@"FundName: %@",label.text);
label.textAlignment = UITextAlignmentCenter;
//label.textColor = [UIColor blueColor];
label.autoresizingMask = UIViewAutoresizingFlexibleRightMargin |
UIViewAutoresizingFlexibleHeight;
[cell.contentView addSubview:label];
return cell;
}
You can add images from documents directory and add them late into the table view as Lazy table images.
For that you can use the following
Take a look at the SDWebImage repository link below.
https://github.com/rs/SDWebImage#readme
This would help you out.
Now there you need to make one small change:
in place of
Happy to Help 🙂