2011-03-02 33 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的建议,它可以解析标题,以便它知道该变量可以以某种方式链接到某个图形控件。