在头文件中的函数中使用 IBOutlet
您能告诉我如何在存储在头文件中的函数中使用 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];
}
帮助我,谢谢
请提前
could you please tell me how i can use IBOutlets in a function stored in the header file:
.h file:
#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];
}
Please help me
thx in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
IBOutlet 对您的代码没有任何影响或效果 - 它是 #define 的!
它用作 Interface Builder 的建议,Interface Builder 可以解析标头,以便它知道该变量可以以某种方式链接到某些图形控件。
An IBOutlet has no impact or effect on your code - it's #defined out!
It is used as a suggestion to Interface Builder, which can parse the header, so that it knows that that variable can become linked to some graphical control in some way.