我只是在Xcode中嘗試一些全新的和簡單的東西。我正在尋找一個教程來創建播放音樂或聲音的按鈕。在預覽時間之前,所有內容似乎都沒問題。 IBAction似乎有一個預期的標識符問題,以及(void)之後的預期標識符問題。但每次我按提示說提示都會增加。我試圖按照他們所說的去做,但之後它不再是同一個功能。有任何想法嗎?試圖在Xcode中創建一個按鈕Objective-C
#import "ViewController.h"
#import <UIKit/UIKit.h>
#import <AudioToolbox/AudioToolbox.h>
@interface StrackerViewController : ViewController
//@end
//@implementation StrackerViewController: ViewController
- (IBAction) epic; {
CFBundleRef mainBundle = CFBundleGetMainBundle();
CFURLRef soundFileURLRef;
soundFileURLRef = CFBundleCopyResourceURL(mainBundle, (CFStringRef) @ "epic", CFSTR ("mp3"),NULL);
UInt32 soundID;
AudioServicesCreateSystemSoundID(soundFileURLRef, &soundID);
AudioServicesPlaySystemSound(soundID);
}
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
你爲什麼使用CoreFoundation? – Droppy
是.h還是.m? – Larme
對不起,這是Viewcontroller.m – reivax7