-2

Sorry if this is a noob question, but All my code is error-free and I cannot figure out how to get the button I press to do all these things. It's connected correctly in interface builder. Anyway, if you can help me out, here's what I have:

IN THE INTERFACE

    @interface SuprisedViewController : UIViewController {

    IBOutlet UIButton *marsStoryButton;
    IBOutlet UIButton *marsStoryHome;

    @property (nonatomic, retain) IBOutlet UIButton *marsStoryHome;
    @property (nonatomic, retain) IBOutlet UIButton *marsStoryButton;
    -(void)marsStoryButtonPressed;

IN THE IMPLEMENTATION

    @implementation SuprisedViewController

    @synthesize bolloLogo, scaryAlien, exorcist, image1, image2, marsMan, marsStoryButton, marsStoryHome;



    -(void)marsStoryButtonPressed {

      marsMan.hidden = NO;
marsStoryHome.hidden = NO;

CFBundleRef mainBundle = CFBundleGetMainBundle();
CFURLRef soundFileURLRef;
soundFileURLRef = CFBundleCopyResourceURL(mainBundle, (CFStringRef) @"longManScream", CFSTR ("wav"), NULL);

soundFileURLRef = CFBundleCopyResourceURL(mainBundle, (CFStringRef) @"spressedScream", CFSTR ("wav"), NULL);

soundFileURLRef = CFBundleCopyResourceURL(mainBundle, (CFStringRef) @"torturedGirlScream", CFSTR ("wav"), NULL);


UInt32 soundID;
AudioServicesCreateSystemSoundID(soundFileURLRef, &soundID);
AudioServicesPlaySystemSound(soundID);

AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);
}

1 Answers1

1

Declare your method in the header file as:

-(IBAction)marsStoryButtonPressed;

Instead of (void). Then in Interface builder you will be able to bind the button to the action by ctrl-dragging from the button to the file's owner (your viewcontroller).

Nick Lockwood
  • 40,865
  • 11
  • 112
  • 103