Using buttons, located on the same xib, to bring up multiple different views

Discussion in 'iOS Programming' started by lindseyv, May 24, 2010.

  1. lindseyv macrumors newbie

    Joined:
    May 24, 2010
    #1
    I am new to objective c development and I have searched for the last couple days on how to solve this problem. Essentially, I am trying to create a main menu for my application that contains three buttons that will load different views depending on the button the the user hits. All of the tutorials I have seen only show one button and every time I add the second, my program crashes. Below is the code that I have put together for two buttons

    The second view is working correctly and the buttons are being connected the same way. The problem starts when I try adding the third view. I have even tried adding two view controllers to direct them.

    In the main.h

    Code:
    @interface ViewViewController : UIViewController {
    
    
    IBOutlet SecondViewController *secondViewController;
    IBOutlet FourthViewController *fourthViewController;
    }
    
    - (IBAction)gotoSecondView;
    - (IBAction)gotoFourthView;

    In the main .m
    Code:
    - (IBAction)gotoSecondView{
    [self presentModalViewController:secondViewController animated:YES];
    }
    
    - (IBAction)gotoFourthView{
    [self presentModalViewController:fourthViewController animated:YES];
    }
    Thank you.
     
  2. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #2
    Where do you create the view controller instances you are displaying?
     
  3. lindseyv thread starter macrumors newbie

    Joined:
    May 24, 2010

Share This Page