I need to create a scrollable composite view on iOS. That is to say, the view will contain at least one image, possibly a button, and some text (that we may wish to format with bold fonts, etc). The amount of data, and particularly the amount of text, is variable, from maybe 4 lines to maybe 100. The data is “variable” to a degree, and in particular the image and text do not come joined at the hip.
This all needs to fit in a “pane” of about 280h x 115w pixels in a portrait-only layout.
A single UITextView doesn’t provide the facilities to display an image or format the text.
A UIWebView provides the ability to display the image and formatted text, but the button is a problem (not even sure if it’s doable).
A UIScrollView would easily allow the image and button, and then a UIWebView could be embedded in the scroll view for the text, but then scrolling becomes a problem — I’d like the entire view to scroll as one, without having to resize the web view to contain it’s content, and without the confusion of a scrollable within a scrollable (the doc warns of “unexpected behavior”).
(I’m guessing your thoughts at this point are that I want too much.)
So, any suggestions? What’s the best way to get close to what I need here?
I suggest testing with a
UIWebViewinside yourUIScrollView. I don’t see any interference in the iOS 5.0 simulator. I don’t know if there are problems in iOS 4.0.If you find that there is interference, you can prevent it by setting the web view’s
userInteractionEnabledproperty to NO, either in the nib or in code. This will prevent the web view from receiving any touches, so the user also won’t be able to pinch-zoom it, follow links in it, or copy text from it.In the web view’s delegate, implement
webViewDidFinishLoad:to set the web view’s size and the scroll view’scontentSize. For example: