Iphone 为什么链接器抱怨缺少符号?

Iphone 为什么链接器抱怨缺少符号?,iphone,cocoa,linker,Iphone,Cocoa,Linker,为什么我会犯这个奇怪的错误? 有什么想法吗 实施: #import "VideoView.h" #import <MediaPlayer/MediaPlayer.h> @implementation VideoView @synthesize player; - (void)playVideoWithURL:(NSURL *)url showControls:(BOOL)showControls { if (!player) { player = [[MP

为什么我会犯这个奇怪的错误? 有什么想法吗

实施:

#import "VideoView.h"
#import <MediaPlayer/MediaPlayer.h>

@implementation VideoView
@synthesize player;

- (void)playVideoWithURL:(NSURL *)url showControls:(BOOL)showControls {
    if (!player) {
        player = [[MPMoviePlayerController alloc] initWithContentURL:url];

        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didFinishPlaying:) name:MPMoviePlayerPlaybackDidFinishNotification object:player];

        if (!showControls) {
            player.scalingMode = MPMovieScalingModeAspectFill;
            player.movieControlMode = MPMovieControlModeHidden;
        }

        [player play];
    }
}

- (IBAction)playVideoWithControls {
    NSString *path = [[NSBundle mainBundle] pathForResource:@"test" ofType:@"mov"];
    NSURL *url = [NSURL fileURLWithPath:path];
    [self playVideoWithURL:url showControls:YES];
}


- (void)didFinishPlaying:(NSNotification *)notification {
    if (player == [notification object]) {  
        [[NSNotificationCenter defaultCenter] removeObserver:self name:MPMoviePlayerPlaybackDidFinishNotification object:player];
        [player release];
        player = nil;
    }
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning]; // Releases the view if it doesn't have a superview
    // Release anything that's not essential, such as cached data
}


- (void)dealloc {
    [super dealloc];
}


@end
#导入“VideoView.h”
#进口
@视频视图的实现
@综合玩家;
-(void)playVideoWithURL:(NSURL*)url显示控件:(BOOL)显示控件{
如果(!玩家){
player=[[MPMoviePlayerController alloc]initWithContentURL:url];
[[NSNotificationCenter defaultCenter]添加观察者:自选择器:@selector(DidFinishPlay:)名称:MPMoviePlayerPlaybackDidFinishNotification对象:player];
如果(!showControls){
player.scalingMode=MPMovieScalingModeAspectFill;
player.movieControlMode=MPMovieControlModeHidden;
}
[玩家游戏];
}
}
-(iAction)使用控件播放视频{
NSString*path=[[NSBundle mainBundle]pathForResource:@“test”类型:@“mov”];
NSURL*url=[NSURL fileURLWithPath:path];
[self playVideoWithURL:url显示控件:是];
}
-(无效)未完成播放:(NSNotification*)通知{
如果(玩家==[通知对象]{
[[NSNotificationCenter defaultCenter]removeObserver:self name:MPMoviePlayerPlaybackDidFinishNotification对象:player];
[玩家释放];
玩家=零;
}
}
-(无效)未收到记忆警告{
[super-didReceiveMemoryWarning];//如果没有superview,则释放该视图
//释放任何不重要的内容,例如缓存数据
}
-(无效)解除锁定{
[super dealoc];
}
@结束
标题:

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


@interface VideoView : UIViewController {
    MPMoviePlayerController *player;

}
@property (nonatomic, retain) MPMoviePlayerController *player;
- (IBAction)playVideoWithControls;


@end
#导入
#进口
@接口VideoView:UIViewController{
MPMoviePlayerController*播放器;
}
@财产(非原子,保留)MPMoviePlayerController*播放器;
-(iAction)使用控件播放视频;
@结束

MPMoviePlayerController位于您忘记链接的MediaPlayer.framework中。

MPMoviePlayerController位于您忘记链接的MediaPlayer.framework中。

什么是“链接到”?我在我的.m和.h文件中添加了它双击“组和文件”树中“目标”下的目标。在第一个选项卡上有一个链接库列表,单击Plus并添加MediaPlayer框架。开始!谢谢你,我从来不知道怎么做。第一次我玩框架,但现在我得到一个错误,声称“[NSCFDictionary playVideoWithControls]:无法识别的选择器发送到实例”。有人能告诉我这是什么意思吗?丹尼尔·金德勒:它的意思和你的“isEqualToString:”之前的例外情况是一样的:你向一个对象发送了一条消息,但该对象没有响应该消息。简而言之,您将消息发送到了错误的对象。您所说的“链接到”是什么意思?我在我的.m和.h文件中添加了它双击“组和文件”树中“目标”下的目标。在第一个选项卡上有一个链接库列表,单击Plus并添加MediaPlayer框架。开始!谢谢你,我从来不知道怎么做。第一次我玩框架,但现在我得到一个错误,声称“[NSCFDictionary playVideoWithControls]:无法识别的选择器发送到实例”。有人能告诉我这是什么意思吗?丹尼尔·金德勒:它的意思和你的“isEqualToString:”之前的例外情况是一样的:你向一个对象发送了一条消息,但该对象没有响应该消息。更简单地说,您将消息发送到了错误的对象。