Junior Bill gates
Junior Bill gates

Reputation: 1866

How to switch from one view to another in iPhone?

I am a beginner in objective-c. Can anyone please tell me how can I switch from one view to another in an iPhone application.

Upvotes: 6

Views: 4484

Answers (2)

vakio
vakio

Reputation: 3177

There are 3 main controllers that can switch views for you:

  • UINavigationController
    • Here you push and pop views in a chain.
    • There will be a navigation bar on top which lets you navigate back to where you came from.
  • UITabbarController
    • Here all the views will be represented by tabs at the bottom of the screen.
    • You can switch back and forward between them by clicking them in the tabbar.
  • UIViewController
    • There is a method in UIViewController wich lets you "present" other viewcontrollers. It's called presentModalViewController:animated:
    • You will have to do your own navigation back to the parent by using dismissViewControllerAnimated:

You can also do your own switching with variations of addSubView: or view.hidden or similar, but I would recommend those 3 to begin with.

Upvotes: 4

Related Questions