I have created an app that is basically a view based app with a scroll view. I was able to get 15 views loaded into my scrollview and I can page from view to view. I made a class for each of these views as I figure each would have their own set of instruction... The scrolling part It works great.....
Trouble I am having is that i want to "trigger" things to happen when different views are shown. I am able to get methods to work when I tie them to a button on interface builder, but how do I make stuff happen "automaticallty" ?
On my Page1View.m ( the first view of the scrollview) :
I have 2 methods:
How do I get the setUpSounds to "trigger" ? If I add [self setUpSounds] to the IBAction I made, I can get it to initialize the sounds, then play it, but I want it to automatically initialize the sounds without a button.
I am sure it is something simple, that I just don't know. I can see that in the ViewController, I can get things to happen automatically if I place them in - (void)viewDidLoad { , but it does not work in my own UIVIew classes.
blade
Code:
-(void)setUpSounds {
NSLog(@"sounds are setup");
NSBundle *mainBundle = [NSBundle mainBundle];
farSound = [[SoundEffect alloc] initWithContentsOfFile:[mainBundle pathForResource:@"farSound" ofType:@"caf"]];
nearSound = [[SoundEffect alloc] initWithContentsOfFile:[mainBundle pathForResource:@"nearSound" ofType:@"caf"]];
levelSound = [[SoundEffect alloc] initWithContentsOfFile:[mainBundle pathForResource:@"levelSound" ofType:@"caf"]];
}
- (IBAction)playTheFarSound {
[farSound play];
}