On 30 Sep 2013, at 15:47, Koen van der Drift <koenvanderdr...@gmail.com> wrote:
> Hi, > > I have a custom UITableViewCell with several labels of which the size needs > to be calculated based on the content. Some of the content is also > constructed on the fly, since I am generating an attributed string, and don't > want to store these in my model objects. > > The frame is calculated in heightForRowAtIndexPath: and layoutSubviews of my > custom cell. The attributed string is calculated in heightForRowAtIndexPath: > and cellForRowAtIndexPath: > > I put in some logs to see the order in which these methods are called, see > below. Surprisingly (at least for me), heightForRowAtIndexPath is called for > every row first, even the ones that are not yet visible. So when my data > array is really large, this could take up some time, and I can see that when > the table is drawn. > > There must be a more clever way to do this? The table has to know how high each row is in order to know how tall it is in total. That information is needed for the scroll indicator. I believe iOS 7 introduces the concept of an estimated height, allowing you to give it a quicker calculation, which later gets refined. _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com