Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I recently had the same issue in one of my apps (navigation style) and the way I solved it is fairly simple.</p> <p>I had a user_type flag in my JSON response, and depending on that flag I would push a different view controller.</p> <p>For example, given my JSON response is stored in a NSMutableDictionary called "response"</p> <pre><code>if ([response objectForKey:@"account_type"] == 1) { /* initialize user_type 1 viewController */ [self.navigationController pushViewController:userType1ViewController animated:YES]; else if ([response objectForKey:@"account_type"] == 2) { /* initialize user_type 2 viewController */ [self.navigationController pushViewController:userType2ViewController animated:YES]; } </code></pre> <p>You can have as many different user_types as you want.</p> <p><em>Editing after clarification in comments</em></p> <p>You will likely be manually drawing these views.</p> <p>I would subclass UIView for each of the different question types you have listed (including properties for common elements like question title, choices, etc). Assuming that questions with the same question type will have the same layout.</p> <p>Then you can cycle through your JSON response (once it's in an array or dictionary) and lay it out.</p> <p>If it's a multiple choice question, make a new multipleChoiceQuestion view, add its properties, then addSubview to the main feed view. Then, for your next view, you will need to set the frame to be:</p> <pre><code>nextQuestion.frame = CGRectMake(0, 0 + firstQuestion.frame.size.height, height, width); </code></pre> <p>This will ensure that your second question is drawn right below the first question.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload