Skip to content

Commit f835eee

Browse files
committed
Update README.md
1 parent e1acd8b commit f835eee

File tree

1 file changed

+33
-2
lines changed

1 file changed

+33
-2
lines changed

README.md

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ If you have a **self-satisfied** cell, then all you have to do is:
2222
}];
2323
}
2424
```
25-
## Advanced usage with height caching
25+
## Height Caching API
2626

27-
Since iOS8, `-tableView:heightForRowAtIndexPath:` will be called more times than we expect, we can feel these extra calculations when scrolling. So we provide another extension with caches:
27+
Since iOS8, `-tableView:heightForRowAtIndexPath:` will be called more times than we expect, we can feel these extra calculations when scrolling. So we provide another API with caches:
2828

2929
```
3030
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
@@ -35,8 +35,39 @@ Since iOS8, `-tableView:heightForRowAtIndexPath:` will be called more times than
3535
}
3636
```
3737

38+
### Auto cache invalidation
39+
3840
Extra calculations will be saved if a height at an index path has been cached, besides, **NO NEED** to worry about invalidating cached heights when data source changes, it will be done **automatically** when you call "-reloadData" or any method that triggers UITableView's reloading.
3941

42+
## Precache
43+
44+
Pre-cache is an advanced function which helps to cache the rest of offscreen UITableViewCells automatically, just in **"idle"** time. It helps to improve scroll performance, because no extra height calculating will be used when scrolls. It's enabled by default if you use "fd_heightForCellWithIdentifier:cacheByIndexPath:configuation:" API.
45+
46+
## Debug log
47+
48+
Debug log helps to debug or inspect what is this "FDTemplateLayoutCell" extention doing, turning on to print logs when "calculating", "precaching" or "hitting cache".Default to "NO", log by "NSLog".
49+
50+
```
51+
tableView.fd_debugLogEnabled = YES;
52+
```
53+
54+
It will print like this:
55+
56+
```
57+
** FDTemplateLayoutCell ** layout cell created - FDFeedCell
58+
** FDTemplateLayoutCell ** calculate - [0:0] 233.5
59+
** FDTemplateLayoutCell ** calculate - [0:1] 155.5
60+
** FDTemplateLayoutCell ** calculate - [0:2] 258
61+
** FDTemplateLayoutCell ** calculate - [0:3] 284
62+
** FDTemplateLayoutCell ** precached - [0:3] 284
63+
** FDTemplateLayoutCell ** calculate - [0:4] 278.5
64+
** FDTemplateLayoutCell ** precached - [0:4] 278.5
65+
** FDTemplateLayoutCell ** hit cache - [0:3] 284
66+
** FDTemplateLayoutCell ** hit cache - [0:4] 278.5
67+
** FDTemplateLayoutCell ** hit cache - [0:5] 156
68+
** FDTemplateLayoutCell ** hit cache - [0:6] 165
69+
```
70+
4071
## About self-satisfied cell
4172

4273
a fully **self-satisfied** cell is constrainted by auto layout and each edge("top", "left", "bottom", "right") has at least one layout constraint against it.

0 commit comments

Comments
 (0)