2011-03-02 29 views
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提前

+0

你輸入了什麼? – LordT 2011-03-02 13:43:05

+0

只是出於好奇..:你爲什麼要用一個函數來解決這個問題,而不是使用常規方法? – Toastor 2011-03-02 13:47:04

+0

我只是在學習Objective-C ..我會如何做到這一點? :( – Chris 2011-03-02 14:03:37

回答

1

IBOutlet對您的代碼沒有影響或影響 - 它被#defined了!

它被用作Interface Builder的建議,它可以解析標題,以便它知道該變量可以以某種方式鏈接到某個圖形控件。