当我尝试使用MPVolumeView进行编译时,xcode出错

时间:2011-11-04 22:44:04

标签: objective-c media-player linker-errors mpvolumeview

xcode给了我这个错误:

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)

这是viewconid的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 个答案:

答案 0 :(得分:3)

在项目中添加MediaPlayer框架:

项目 - &gt; 构建阶段 - &gt; 将二进制文件链接到库:

enter image description here

答案 1 :(得分:2)

错误表示链接器找不到类MPVolumeView

您需要将包含此类的库或框架添加到XCode