1

你能告诉我如何在存储在头文件中的函数中使用 IBOutlets:

.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];
    }

请帮我

提前谢谢

4

1 回答 1

1

IBOutlet 对您的代码没有影响或影响 - 它是#defined out!

它被用作对可以解析标题的 Interface Builder 的建议,以便它知道该变量可以以某种方式链接到某些图形控件。

于 2011-03-02T13:54:29.333 回答