ok i have a question...do you know how to create actions and buttons?
if not you will learn here
ok first here is what you will need
1) A picture of a apple or what ever you want it to say.
2)A Voice record of you or some one else saying the name of the object.
after you have these read this
First open finder and find you picture and the sound/voice
then drag the the picture into xcode in the other Resources file then you will get a message at the top there is a box that says somthing like copy items to folder or somthing ccheck that box then do the same thing with you applce picture.
Then under the FrameWorks folder in xcode right click on UIKit.framework then reveal in finder. Then scroll up (in finder) unitll you see the folder AVFoundationframework. Drag that folder into the frame works folder in xcode. WHEN THE MESSAGE COMES UP TO COPY DO NOT CHECK THE BOX TO COPY THE FILE it will give you errors.
Now go into you .h file under Classes (if you stared a new project click the second .h file)
and under the
Code:
@interface PROJECT NAME : UIViewController {
}
under the }
type
that is if you sound is some one saying apple
then go to your .m file under classes (if you have a new project the send .m)
then under
Code:
#import "PROJECT NAME.h"
type
Code:
#import<AVFoundation/AVAudioPlayer.h>
then under where it says
@implementation PROJECT NAME
type
Code:
- (IBAction)apple {
NSString *path = [[NSBundle mainBundle] pathForResource:@"appleVoice" ofType:@"mp3"];
AVAudioPlayer* theAudio = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:NULL];
theAudio.delegate = self;
[theAudio play];
}
This is very important when it says
Code:
NSString *path = [[NSBundle mainBundle] pathForResource:@"appleVoice" ofType:@"mp3"];
change appleVoice to what ever file name the audio was
ALSO change the .mp3 to what ever kind of sound file the sound is
Now we are almost done
double click
PROJECTNAME.xib
then create a Round rect button
then go to the "Button Attributes"
find where it says "Type round rect" change it to custom
then underthat find where it says "image"
drop that menu down and find you apple piccture and select that.
now the button should have a apple.
Then click files Owner on the little box and hit control on your key board and drag to the button then it sould pop up with a menu
If you want the sound to play right whne the user hits his finger on it choose "touch down"
If you want it to be when the user takes his finger off the button to play the sound choose "Touch Up Inside"
Save that and build and go it should work
You can repeat this to have multiple sounds when you click diffrent buttons
the only step you dont have to repeat is when we typed
Code:
#import<AVFoundation/AVAudioPlayer.h>
If this didnt work or your having problems tell me and i will create you a project and email it to you if you need that just send me a private message with your email
Hope i helped