0

Is it possible to create a viewcontroller that could handle 5 views? And is it possible to implement a different button on every view to make a transition to root view?

So my idea of the app is when I load it it takes me to main window, and on that window there will be 5 button that will take me to the 5 views, and after I'm in that view, among other buttons there will be just one button that will take me only to the MainView.

Let's say that some of those 5 views will be Options, Score, Statistics, something like that.

If it is possible to make an app like that using so much views, is it a good approach?

vburojevic
  • 1,666
  • 5
  • 24
  • 34

1 Answers1

0

This would be possible, but from what you describe, it does not sound like a good idea. I would suggest instead making a Tab Bar app, and having a separate view controller for each of your 5 views.

If you do not want to make a tab bar app, you can certainly do what you describe, but I would recommend having a separate view controller instance for each view. You could have your 5 buttons in your main view, and each button could push a modal view with no animation. You could then add whatever transition animation you want. In your modal view, you could have a button that pops the modal view.

In your main view controller, you would do this:

- (IBAction)button1Click {

    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:0.5];
    [UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.view cache:YES];

    UIViewController *newController = [[UIViewController alloc] initWithNibName:@"View1" bundle:nil];
    [self presentModalViewController:newController animated:NO];
    [newController release];

    [UIView commitAnimations];

}

And in your view 1 controller:

- (IBAction)backToMainClick {

    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:0.5];
    [UIView setAnimationTransition:UIViewAnimationTransitionCurlDown forView:self.view cache:YES];

    [self dismissModalViewControllerAnimated:NO];

    [UIView commitAnimations];

}
Katfish
  • 698
  • 7
  • 13
  • I was thinking about creating 5 buttons, and four of them would be shown on mainview, and after one of them is clicked those four would hide and go to other view where would another button appear which would take me to main view again, is it a good idea? Tab bar wouldn't fit my app – vburojevic Jun 26 '11 at 07:50
  • It could work if you do something like I suggest in my edited comment. Instead of custom animations, you could also use a navigation controller, and have each button just push a new view on to the navigation controller. – Katfish Jun 26 '11 at 07:55