0

アプリのコーディングに問題があります。実行しようとすると、不完全な実装でエラーが発生します。

ViewController.m のコードは次のとおりです。何が間違っているのか教えてください。

.m のコードの下に ViewController.h のコードも含めます。

ViewController.m

#import "ViewController.h"
#import "SecondViewController.h"

@interface ViewController ()

@end

@implementation ViewController

 -(IBAction)infoButtonpressed:(id)sender;
 {
SecondViewController *second = [[SecondViewController alloc] initWithNibName:nil bundle:nil];

second.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:second animated:YES];

}

-(IBAction)sound1 {

CFBundleRef mainBundle = CFBundleGetMainBundle();

CFURLRef soundFileURLRef;

soundFileURLRef = CFBundleCopyResourceURL(mainBundle, (CFStringRef) @"sound1", CFSTR("wav"), NULL);

UInt32 soundID;

AudioServicesCreateSystemSoundID(soundFileURLRef, &soundID);

AudioServicesPlaySystemSound(soundID);

}

-(IBAction)sound2 {

CFBundleRef mainBundle = CFBundleGetMainBundle();

CFURLRef soundFileURLRef;

soundFileURLRef = CFBundleCopyResourceURL(mainBundle, (CFStringRef) @"sound2", CFSTR("wav"), NULL);

UInt32 soundID;

AudioServicesCreateSystemSoundID(soundFileURLRef, &soundID);

AudioServicesPlaySystemSound(soundID);

}

-(IBAction)sound3 {

CFBundleRef mainBundle = CFBundleGetMainBundle();

CFURLRef soundFileURLRef;

soundFileURLRef = CFBundleCopyResourceURL(mainBundle, (CFStringRef) @"sound3", CFSTR("wav"), NULL);

UInt32 soundID;

AudioServicesCreateSystemSoundID(soundFileURLRef, &soundID);

AudioServicesPlaySystemSound(soundID);

}

-(IBAction)sound4 {

CFBundleRef mainBundle = CFBundleGetMainBundle();

CFURLRef soundFileURLRef;

soundFileURLRef = CFBundleCopyResourceURL(mainBundle, (CFStringRef) @"sound4", CFSTR("wav"), NULL);

UInt32 soundID;

AudioServicesCreateSystemSoundID(soundFileURLRef, &soundID);

AudioServicesPlaySystemSound(soundID);

}

-(IBAction)sound5 {

CFBundleRef mainBundle = CFBundleGetMainBundle();

CFURLRef soundFileURLRef;

soundFileURLRef = CFBundleCopyResourceURL(mainBundle, (CFStringRef) @"sound5", CFSTR("wav"), NULL);

UInt32 soundID;

AudioServicesCreateSystemSoundID(soundFileURLRef, &soundID);

AudioServicesPlaySystemSound(soundID);

}

-(IBAction)sound6 {

CFBundleRef mainBundle = CFBundleGetMainBundle();

CFURLRef soundFileURLRef;

soundFileURLRef = CFBundleCopyResourceURL(mainBundle, (CFStringRef) @"sound6", CFSTR("wav"), NULL);

UInt32 soundID;

AudioServicesCreateSystemSoundID(soundFileURLRef, &soundID);

AudioServicesPlaySystemSound(soundID);

}

@end

ViewController.h

#import <AudioToolbox/AudioToolbox.h>

@interface ViewController :UIViewController {

}

-(IBAction)switchviews;

-(IBAction)sound1;

-(IBAction)sound2;

-(IBAction)sound3;

-(IBAction)sound4;

-(IBAction)sound5;

-(IBAction)sound6;

-(IBAction)infoButtonpressed:(id)sender;

@end
4

2 に答える 2

2
-(IBAction)switchviews;

ヘッダー ファイルで宣言されていますが、実装 ( .m) ファイルでは実装されていません。

于 2012-09-22T09:16:01.643 に答える
0

@H2CO3-正しい

アプリケーション-(IBAction)switchviews;ではファイルで宣言されて.hいますが、ファイルで宣言されていません.m。したがって、最初に-(IBAction)switchviewsを宣言する必要があります。.m関連するコードを含むファイル内のメソッド。

于 2012-09-22T09:24:47.923 に答える