【问题标题】:Incomplete implemention - @implementation View Controller不完整的实现 - @implementation 视图控制器
【发布时间】:2012-09-14 13:55:23
【问题描述】:

我在编写应用程序时遇到了一些问题,当我尝试运行时,它会出错,导致实现不完整。

这是 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

【问题讨论】:

    标签: iphone xcode ios5 ios6 iphone-5


    【解决方案1】:
    -(IBAction)switchviews;
    

    在您的头文件中声明,但从未在实现 (.m) 文件中实现。

    【讨论】:

    • @RupertBuesst 不客气。如果有帮助,请在可能的情况下接受我的问题。
    【解决方案2】:

    @H2CO3 - 是对的

    在您的应用程序中,-(IBAction)switchviews; 已在 .h 文件中声明,但未在 .m 文件中声明。所以首先你需要声明 -(IBAction)switchviews; .m 文件中的方法以及相关代码。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-07-16
      • 2012-03-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多