Folks,
coming from the Java/Swing world, I am sometimes puzzled by the UI programming on the iPhone. I've spent the last hours with Googling for information but it seems that I asked the wrong questions by thinking too much in Java. Could you please point me to resources to get more familiar with the GUI concepts to be able to achive the following functionality:
Basically, I want to create a vertically scrollable view that represents structured text (for example, a recipe). Each step consists of a title and a textual description. As I want to fold and unfold such steps, the title would be somehow interactive and by clicking it the description would be displayed or hidden.
In Java, I would create a component that renders one such section. The layout manager would compute the components preferred height (with or without description being displayed).
Then, in Java, I would create a panel with a vertical layout manager and sequentially add my components. This panel would be placed in a scroll pane; the scroll pane would ask the panel to layout itself and then show a viewport on it, if for example the height is bigger than the scroll pane's height.
What Java provides me is:
- layouting of elements (computing their preferred height and width), thus no need to deal with coordinates and dimensions
- dynamic creation of UIs by creating and adding components during runtime
What I understood on the iPhone:
- I can dynamically add views as subview to a view, e.g. a scrollview by calling addSubview
- I can even remove that stuff using removeFromSubview (as explained here http://efreedom.com/Question/1-3062848/Clear-Content-UIScrollView)
What I don't understand on the iPhone:
- does one view always correspond to a visible screen (I did use tab and navbar navigation so far and there whenever I set a new view, it fills the current visible screen minus the space needed for the two bars)?
- or is it possible to define a view that contains a label on top ("north") and a text in center; if so, could such a view automatically determine its height?
- can I realize my example in a similar way like in Java or would I need to calculate all dimensions and coordinates of the individual components on my own? (This example seems to touch on that topic: http://stackoverflow.com/questions/3406721/iphone-scrollview-add-elements-dynamically-with-id)
Alternatively, could I use a WebView and render my stuff as local HTML using JavaScript to show or hide nodes?
Thanks for any hint or link!