Sunday, April 3, 2011

How to switch views by buttons on iPhone?

I want to switch 3 views and let them switch from 1-2-3. The first view is to let users input name and password, the second view will show his information to let him confirm and the third view will show him a list of options so he can choose what to do next.

The problem is how to switch these views? If I use a navigation controll to switch views, how can I add textfield in it so users can input their infomation?

From stackoverflow
  • Check out Apple's sample TableViewSuite application for hints. You'll find more sample code at Apple's iPhone Developer site.

    UltimateBrent : That example doesn't have any view switching, only subviews of tables.
    Alex Reynolds : It demonstrates the navigation pattern for view switching.
  • You hate to write your code into

    -(void)IBAction

    set the button property by using connection Inspector set the button to touchesDown. After this the view which you want to see at the beginning. Make it's alpha value 1 and other view's alpha value should be 0. After filling all information when you will click on button. Make alpha value of first view should be 0 and the second view's alpha should be 1. Like that you can proceed

  • Thanks for your answers and I find this isn't so complicated as I thought earlier. After a few attempts, I finally made it. I just use NavigationController to switch between UIViews.

    Now I understand that navigation controller can swith not only from UITableView to UIView, but also from UIView to UIView. Using a UIView class, I can organize all the controls easily in IB.

0 comments:

Post a Comment