ViewController [Xcode]的不完整实现

时间:2012-11-29 04:56:18

标签: xcode implementation viewcontroller

对于Xcode(appstore上只有1个应用程序),我有点新手。我正在尝试创建一个新的应用程序,并开始从按钮播放声音的基本功能,一旦我开始工作我计划让用户更改设置等。无论如何,当我运行项目时,我得到一个错误@implementation ViewController中的ViewController.m说“不完整的实现”。我的其他应用程序没有发生这种情况,我已经通过复制来自该应用程序的所有代码进行了测试,但它仍然无法正常工作。 这是我的ViewController.h代码:

#import <UIKit/UIKit.h>
#import <AudioToolbox/AudioToolbox.h>

@interface ViewController : UIViewController{
}
-(IBAction)sound1;
@end

这是我的ViewController.m代码:

#import "ViewController.h"

@implementation ViewController

-(IBAction)sound1 {
CFBundleRef mainBundle = CFBundleGetMainBundle();
CFURLRef soundFileURLRef;
soundFileURLRef = CFBundleCopyResourceURL(mainBundle, (CFStringRef) @"sound1", CFSTR          ("mp3"), NULL);

UInt32 soundID;
AudioServicesCreateSystemSoundID(soundFileURLRef, &soundID);
AudioServicesPlaySystemSound(soundID);
}
- (void)didReceiveMemoryWarning{
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}

#pragma mark - View lifecycle

- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
} 

- (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}

- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
}

- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
}

- (void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
}

- (void)viewDidDisappear:(BOOL)animated
{
[super viewDidDisappear:animated];
}

- (BOOL)shouldAutorotateToInterfaceOrientation:   (UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return interfaceOrientation == UIInterfaceOrientationPortrait;

}

@end

我做错了什么?我工作的每个项目都会发生这种情况,问题是什么?我搜索了其他问题,但没有完全理解(我相当新) 谢谢你的帮助

1 个答案:

答案 0 :(得分:1)

我遇到了同样的问题,并在此处找到答案:Incomplete Implementation in Objective-C Class

希望它对你有所帮助。