Given a collection of Word objects, I want to display a scrollable tag cloud similar to what is shown below. My Word class has properties for Name and Rank from which I will determine sorting and weighting of the fonts. Each word should be a selectable object (for invoking some event). Since the collection can contain thousands of objects, I only 开发者_如何学Pythonneed to manage words that are currently presented in the view (i.e., as they scroll off the bottom or top of the screen, I no longer care about them).
How would you approach this?
Put HTML-formatted text into a UIWebView
with some JavaScript that scrolls on some timed basis. You might be able to handle touch events on elements via a JavaScript bridge.
Failing that, you'll need a bunch of UILabel
elements of various sizes, and a layout manager that positions them appropriately, which will almost certainly be a lot more work.
I ended up using a UITableView with a custom UITableViewCell containing an array of custom labels. With proper use of lazy loading and background processing, it is plenty fast. I'll go ahead and mark mine as the accepted answer, but I do appreciate all of the responses.
精彩评论