From 54f0113c0c08caf1bf6abc53d6872df6ade8aac5 Mon Sep 17 00:00:00 2001 From: Lukhnos Liu Date: Wed, 16 Jan 2013 21:42:41 -0800 Subject: [PATCH] Avoid layout when providing cell values (fixes #73) -tableView:objectValueForTableColumn:row: may call -layoutCandidateView, which in turn may force the table view to reload; the layout code should only run after all cell values are provided for to break this potential cycle. --- Source/CandidateUI/VTVerticalCandidateController.m | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Source/CandidateUI/VTVerticalCandidateController.m b/Source/CandidateUI/VTVerticalCandidateController.m index b49472f8..7b78bd38 100644 --- a/Source/CandidateUI/VTVerticalCandidateController.m +++ b/Source/CandidateUI/VTVerticalCandidateController.m @@ -338,6 +338,12 @@ static const CGFloat kCandidateTextLeftMargin = 8.0; } - (void)layoutCandidateView +{ + [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(deferredLayoutCandidateView) object:nil]; + [self performSelector:@selector(deferredLayoutCandidateView) withObject:nil afterDelay:0.0]; +} + +- (void)deferredLayoutCandidateView { NSUInteger count = [_delegate candidateCountForController:self]; if (!count) {