最近在用 DTAttributedTextContentView (DTCoreText) 做图文混排,图片都是 lazy load 的,图片加载完成后,有个回调方法 - (void)lazyImageView:(DTLazyImageView *)lazyImageView didChangeImageSize:(CGSize)size ,这里可以获得图片的高度,或者重新计算 DTAttributedTextContentView 的高度。
那么问题来了,图片加载后 DTAttributedTextContentView 的高度肯定会增加,这个 DTAttributedTextContentView 是在一个 UITableViewCell 里的,如何对它重绘?如果调用
[tableview reloadRowsAtIndexPaths:[NSArray arrayWithObject: xxxIndexPath] withRowAnimation:UITableViewRowAnimationAutomatic]
这个方法,这个 cell 还是会被重新加载,高度还是重新计算,成为一个死循环。
我在做的是 iOS8 only app, TableViewCell 用的是约束布局。 似乎调用 [cell setNeedsDisplay] 也是没效果的