iphone uitableview or uiscrollview better?
Regarding on negative commenst here I simplify my question in small steps
I have a view based application which communicates with a web service and recives xml, parse xml and map its contens an appropriate view component (e.g if thats a date show the question wi开发者_StackOverflow社区th datepicker, if question has 2 values show it with a segmented control, if more with a pickerview..etc) so its a dynamic questionary with many pages.
1-App Receive XML
2-Parse XML and get the latest un-answered questions (there can be unlimited number of questions per each page), each question need to be asked with either a textbox or picker view or segmented control depending on the question type, also it may need a few labels for explanition, and validation alerts, and the question label. Each question and label should have different fonts and colors, defined in xml.
3- User answers all questions inhe page and press send button.
4-Web service receives, checks the answers and sends back new question(s) to be asked depending on the answers given.
5-APP receives new XML (each XML includes whole the state i.e all the previous answered questions) and parse to find out the latest unanswered questions.
6-User again answers and sends the questions and wait for the next set of questions until there are no questions to be asked
7-OR user may want to go back and edit some questions in previous pages. BUT if he edits any question in previous pages then the pages answered after that page are not valid anymore, because each set of question server sends depends on the previosly answered questions, so it needs to delete all the later questions from XML and sends back a request as if it was the latest page waiting for a response.
Question:
1-Should I use UiScrollView or TableView? and what is the general object oriented design here
You can use any of them, depends on the scenario. The tableView offers a very good memory management model by default but with scrollView you need to manage memory yourself, managing means if you put so many UI elements on the scrollView, your app might start receiving memory warnings or in the worst case can get crashed. The reusability of table cells allows you to put much more content without overloading memory, provided if you use it sensibly. You just need to work on the custom tableView cells to get a view needed to display your questions.
If you want many questions in a list, and its an unknown number, you should defenitly use a tableview. Then you'll have much greater performance, and it will be easier to code.
You should use a UINavigationController
and inside of each view in there, display all questions using a UITableView
(i.e., push a UITableViewController
on the navigation controller).
The navigation controller allows for representing in natural way the interaction you describe with your server and also allows to go back through the sets of questions (while also making not valid any pages after the one you go back to).
精彩评论