2011-11-04 73 views
0

Xcode中给我的错误编译:错误在Xcode使用MPVolumeView

Undefined symbols for architecture i386: 
    "_OBJC_CLASS_$_MPVolumeView", referenced from: 
    objc-class-ref in VolumeViewController.o 
    ld: symbol(s) not found for architecture i386 
    clang: error: linker command failed with exit code 1 (use -v to see invocation) 

这是视图控制器的viewDidLoad中。

- (void)viewDidload{ 
    [super viewDidUnload]; 
    MPVolumeView *volumeView = [[[MPVolumeView alloc] initWithFrame:CGRectMake(0, 0, 200, 20)] autorelease]; 
    volumeView.center = CGPointMake(160,134); 
    [volumeView sizeToFit]; 
    volumeView.showsVolumeSlider=YES; 
    [self.view addSubview:volumeView]; 
} 

我输入:

#import <MediaPlayer/MPVolumeView.h> 

可能是什么错误?

回答

2

错误说,链接器无法找到类MPVolumeView

您需要添加包含这个类的XCode

+0

:)很简单!非常感谢! – JackTurky

2

添加MediaPlayer的框架,项目库或框架:

项目- >构建阶段- >带库的链接二进制:

enter image description here