How to load a view from a button?

Discussion in 'iOS Programming' started by tombuarts, Feb 24, 2010.

  1. tombuarts macrumors newbie

    Jan 30, 2010
    I am working on an app that currently has 3 views that load from a main view. They are controlled by 3 buttons on the main view that swap out each view. I would like to add a new view that is controlled by a button on one of the 3 individual views. I want this view to either be modal or simply be "on top" of the other views until it is dismissed. Is there a way to load this view easily? All sample code I have seen seems to be awfully complicated for something that seems as easy as loading a view. Any help would be greatly appreciated.
  2. marlenez macrumors newbie

    Aug 25, 2008
    Set up an action method for a button on the view that you want to click to present another view. Put it in the view controller of the view you want to have the button in.

    Hope that makes sense - if you need a code snippet let me know.
  3. dejo Moderator


    Staff Member

    Sep 2, 2004
    The Centennial State
    Fairly easily, using something known as presenting a modal view.

    Check out the AddMusic, CoreDataBooks, CryptoExercise, iPhoneCoreDataRecipes, MailComposer samples apps. Once you looked into those, you can probably google to find a simple tutorial that goes over the technique (and UIViewController instance method you will be using).

Share This Page