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

1 iphone linker cocoa

为什么我会遇到这个奇怪的错误? alt text http://img266.imageshack.us/img266/2203/help.tif 任何想法?

执行:

#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
Run Code Online (Sandbox Code Playgroud)

标题:

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


@interface VideoView : UIViewController {
    MPMoviePlayerController *player;

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


@end
Run Code Online (Sandbox Code Playgroud)

Nik*_*uhe 5

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

  • 双击"组和文件"树中"目标"下的目标.在第一个选项卡上有一个链接库列表,单击加号并添加MediaPlayer框架. (5认同)