0

I have an application of proof of simulated, which have some modules, and one of this is a screen which need be reloaded for exhibition of same data. Example: I have screen of the question and answers. Like below

Question: bla bla bla?

Item A: X

Item B: Y

Item c: Z

...

the screen remains the same, what needs to be change is the question and answer content item A, item B, etc..

And, I'm loading the informations "hardcode". I'm sure there are other better choice to make this ^^. I would like to use the same screen to load the features. How I can make this? I was looking to page controller, but it's not what I want, I would like to use a navigation controller to navigation with the screens. I have a dictionary of a list of all the questions with answers: itemA, itemB, etc. how I can load this in the "same screen" with the option of next > and < previous?

Kampai
  • 22,848
  • 21
  • 95
  • 95

1 Answers1

0

A simple one solution is create one UIView add all question and answer related views in it.

  1. Create one UIView add all question and answer related views in it
  2. Create next/previous UIButtons
  3. Add and remove this view on next/previous events and reload inner view content.
  4. Use below method for animation which looks like a navigation next/previous

In below method self.questionPaperView is a which will be animated and it contains all question and answer related views.

Note: Create a global variable for questionPaperView and for inner views. So you don't need to add questions/answers subviews every time you add/remove questionPaperView.

- (void) removeQuestionPaper {
    [UIView animateWithDuration:0.35f animations:^{
        [self.questionPaperView removeFromSuperview];                       
        [self.view layoutIfNeeded];

    } completion:^(BOOL finished) {
        // Call data reload method here.
    }];
}



- (void) addQuestionPaper  {

    [self.view addSubview:self.questionPaperView]

    CATransition *animation = [CATransition animation];
    [animation setDuration:0.5];
    [animation setType:kCATransitionFade];
    [animation setSubtype:kCATransitionFromRight]; // For previous use kCATransitionFromLeft
    [animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
    [[theWindow layer] addAnimation:animation forKey:@"NextView"];
}
Kampai
  • 22,848
  • 21
  • 95
  • 95
  • but how I will control the components position in new screens? I have a method to make this, but no idea how make in case adding new views.. my project are [here](https://github.com/guiltm/Simulado-PMP) – Thiago Montenegro Nov 06 '14 at 01:04
  • 1
    I understand now, I was maked it.. but without animation, with animation was good ;D Im just trading the content of view, and using a animation to give me good effect, but Im using animation of [here](http://stackoverflow.com/questions/5435547/page-curl-on-ios) ,but u answer cleared my head :) – Thiago Montenegro Nov 07 '14 at 04:45