1
請你告訴我,我怎麼能存儲在頭文件中的函數使用IBOutlets:使用IBOutlet中在頭功能文件
.h文件中:
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#import <AVFoundation/AVFoundation.h>
@interface MainView : UIView <AVAudioPlayerDelegate> {
IBOutlet UILabel *SoundDescriptionLabel;
IBOutlet UIBarButtonItem *StopSoundButton;
}
- (IBAction)PlayFatGuyWalking:(id)sender;
- (IBAction)PlayRoadRunner:(id)sender;
- (IBAction)ShowInfoPopup:(id)sender;
- (IBAction)PlayChaosRunning:(id)sender;
- (IBAction)PlaySadTrombone:(id)sender;
- (IBAction)PlayBadJokeSound:(id)sender;
- (IBAction)PlayHorrorSynth:(id)sender;
- (IBAction)PlayLKWPeep:(id)sender;
- (IBAction)PlayUiToll:(id)sender;
- (IBAction)StopSound:(id)sender;
AVAudioPlayer *theAudio;
@end
//PlaySound Function
void playSound(NSString *filename,NSString *type){
[theAudio stop];
NSString *path = [[NSBundle mainBundle] pathForResource:filename ofType:type];
theAudio = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:NULL];
//HERE I WOULD LIKE TO DO THIS:
StopSoundButton.enabled=1;
//END OF WHAT I'D LIKE TO DO
[theAudio play];
}
請幫我
thx提前
你輸入了什麼? – LordT 2011-03-02 13:43:05
只是出於好奇..:你爲什麼要用一個函數來解決這個問題,而不是使用常規方法? – Toastor 2011-03-02 13:47:04
我只是在學習Objective-C ..我會如何做到這一點? :( – Chris 2011-03-02 14:03:37