6

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.

tokyovariable
  • 1,656
  • 15
  • 23
Junior Bill gates
  • 1,858
  • 4
  • 20
  • 33
  • 1
    You should be more specific about exactly what you are trying to do. Are you using a navigation controller or a tab bar controller? Have you looked at any of Apple's sample code? Have you read any documentation? – Kristopher Johnson May 05 '11 at 12:39
  • 1
    Possible duplicate of http://stackoverflow.com/questions/4845188/how-to-switch-from-one-view-to-another – Kristopher Johnson May 05 '11 at 12:40

2 Answers2

4

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.

vakio
  • 3,134
  • 1
  • 22
  • 46