开发者

How would you design a question/answer view (iPhone SDK)

I'm new to iPhone development, and I have a question on how to create a view for my application.

The view should display a problem (using formatted/syntax highlighted text), and multiple possible answers. The user should be able to click on an an开发者_C百科swer to validate it.

Currently, I am trying to use a UITableView embedding UIWebView as contentView. That allows me to display formatted text easily. The problem is that it is a real pain to compute and adjust the height of the cells. I have to preload the webview, call sizeToFit, get its height, and update the cell accordingly. This process should be done for the problem and the answers (as they are HTML formatted text too).

It's such a pain that I am planning to switch to something else. I thought using only a big UIWebView and design everything in HTML. But I looked at some articles describing how to communicate between the HTML page and the ObjectiveC code. This seems to involve some awful tricks too...

So... that's it, I don't really know what I should do. I guess some of you dealt with such things before, and would provide some greatly appreciated tips :)


The catch here is that the iPhone API does not yet support NSAttributedString so you can't just set the text to appear as you would like in a textview.

I saw one work around which essentially used individual UILabels to represent each attribute run. (Can't find the link now.) They used NSString UIKit extensions to calculate the position of the strings on the view and then used that to position the labels.

Another work around would be to draw the strings with their attributes to a UIImage and then just display the image. That would be the easiest solution I think.

In either case your going to have to basically recreate the data structure of an attributed string.

NSAttributedString does a lot of work for us. We really miss it when it is gone.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜