Showing and hiding multiple subviews on view from NIB files
I wonder if someone can help me understand something about how to best implement a combination of a view and and several subviews.
I want to display a questionnaire. There will be a question at the top of the view and an answer area below.
The answer area will first display a set of answer choices, and then the user will select one and I would like it to flip the answer subview and display the correct answer on another subview.
I have made this work by creating a view and placing three subviews on it: 1) a text view at the top for the question; 2) a table list view to show the answer list; and 3) a text view to show the correct answer. I position and hide and show the answer list view and the answer text views on the bottom of the root view.
But what I would like to do is use Interface Builder to create several different subviews to show the user the answers in different formats(a list view, an image view, a button view and a slider view) and then at run time "drop appropriate answer subview on the bottom of my question view", depending on the requirements of each question. So one question might have 4 text answer choices and they would be shown in a list view, another question might show 4 images and the user would touch the correct image....
When they make their choice I would like to flip the answer choice subview over and display the correct answer subview. Ideally the correct answer subview might be one of several formats (each with their own subview). I would like to design all these subviews in IB.
What I want to know is how can I instantiate a subview from an IB bundle and place it in a rectangle at the bottom of my full screen question view.
Question 1 might use Subview-AnswerFormat1 (for example a table list view) to display a list of 4 possible text answers, and Question 2 might load and display Subview-AnswerFormat2 (formatted with 4 images) to display its answers.
I am unclear on is how to load and direct the subview (stored in a NIB file) to be displayed on only a portion of the current view (my question view - which covers the whole window). The answer subviews would all be displayed on the lower half of the screen.
Secondly, should I create multiple views in the questionView nib and load them and manage them through one view controller(seems prone to complexity and errors)?
Or should I create multiple nib files, one for each of the alternative "answer choice subviews"? Then I would load that subview with its own view controller. That is appealing because it would allow me to isolate the work it takes to load, display and input the correct answer for each on the different subviews. And I could add additional subview formats and make them largely self contained.
I will appreciate any suggestions on how to best implement this idea.
|