IPhone : What is the best practice to create application which shows 50 objective questions one by one
IPhone : What is the best practice to create application which shows 50 objective questions one by one. End of the test user should be able to see the score on the UI. For storing the questions am using SQLLite DB, stored all my questions in a table and retrieved/stored locally in to NSMu开发者_运维知识库table Array. Now I have no idea how to navigate between questions "One By One" I guess UI navigation is one I want but Am puzzled how to use UI Navigation view to show question one by one , please correct me if am wrong.
The easiest way is probably UINavigationController with a UIViewController for each question. The problem is that you have 50 elements to be shown and probably that is too much (Because you surely get at least memory warnings)
In order to avoid memory warnings and to do this efficiently you want to implement a 3-views stack-like structure. For instance, views will be A,B and C.
...C←→A←→B←→C←→A...
For example you an in B, then you want to navigate to the previous(left) question you will save current question state, load in A and its state the previous view and show it. Now next and previous questions will be loaded in B and C views respectively. Not complicated, right?
You can simulate this structure with a UINavigationController and 3 UIViewControllers, each UIViewController should be able to load and save a question with its state just before appearing and disappearing.
You can navigate programmatically using the following methods from UINavigationController and get animated transitions for free ;)
– pushViewController:animated:
– popViewControllerAnimated:
Hope it helps
I recently created an App like this for a client. My strategy was to have an IntroViewController, QuestionViewController, and ScoreViewController.
The QuestionViewController housed a UIControl subclass I created to visualize a Question object. The QuestionViewController interacts with a TestManager object to pull the list of questions, it responds to the input from the UIControl subclass, then assign a new question to the UIControl.
My strategy keeps memory low by avoiding creating a huge stack of view controllers. I utilized CATransitions to give the user a sense of new screens for each question.
精彩评论