访问相机视图并在ios5中捕获图像使用哪个框架?

时间:2012-03-21 07:44:33

标签: iphone ios5 avfoundation

在使用ios 5 AVFoundationFramework之前,它不能与ios5 storyboard应用程序一起使用 给出链接错误 即使我添加框架 请帮帮我。

下面给出的方法给出了前3或4个错误。

  - (id) init
{
    self = [super init];
    if (self != nil) {

        void (^deviceConnectedBlock)(NSNotification *) = ^(NSNotification *notification) {
            AVCaptureDevice *device = [notification object];

            BOOL sessionHasDeviceWithMatchingMediaType = NO;
            NSString *deviceMediaType = nil;
            if ([device hasMediaType:AVMediaTypeAudio])
                deviceMediaType = AVMediaTypeAudio;
            else if ([device hasMediaType:AVMediaTypeVideo])
                deviceMediaType = AVMediaTypeVideo;

            if (deviceMediaType != nil) {
                for (AVCaptureDeviceInput *input in [session inputs])
                {
                    if ([[input device] hasMediaType:deviceMediaType]) {
                        sessionHasDeviceWithMatchingMediaType = YES;
                        break;
                    }
                }

                if (!sessionHasDeviceWithMatchingMediaType) {
                    NSError *error;
                    AVCaptureDeviceInput *input = [AVCaptureDeviceInput deviceInputWithDevice:device error:&error];
                    if ([session canAddInput:input])
                        [session addInput:input];
                }               
            }

            if ([delegate respondsToSelector:@selector(captureManagerDeviceConfigurationChanged:)]) {
                [delegate captureManagerDeviceConfigurationChanged:self];
            }           
        };
        void (^deviceDisconnectedBlock)(NSNotification *) = ^(NSNotification *notification) {                       
            if ([delegate respondsToSelector:@selector(captureManagerDeviceConfigurationChanged:)]) {
                [delegate captureManagerDeviceConfigurationChanged:self];
            }           
        };

        NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
        [self setDeviceConnectedObserver:[notificationCenter addObserverForName:AVCaptureDeviceWasConnectedNotification object:nil queue:nil usingBlock:deviceConnectedBlock]];
        [self setDeviceDisconnectedObserver:[notificationCenter addObserverForName:AVCaptureDeviceWasDisconnectedNotification object:nil queue:nil usingBlock:deviceDisconnectedBlock]];
        [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
        [notificationCenter addObserver:self selector:@selector(deviceOrientationDidChange) name:UIDeviceOrientationDidChangeNotification object:nil];
        orientation = AVCaptureVideoOrientationPortrait;
    }
    return self;
}

    Undefined symbols for architecture i386:
  "_OBJC_CLASS_$_AVCaptureDeviceInput", referenced from:
      objc-class-ref in AVCamCaptureManager.o
  "_OBJC_CLASS_$_AVCaptureStillImageOutput", referenced from:
      objc-class-ref in AVCamCaptureManager.o
  "_OBJC_CLASS_$_AVCaptureSession", referenced from:
      objc-class-ref in AVCamCaptureManager.o
  "_OBJC_CLASS_$_AVCaptureDevice", referenced from:
      objc-class-ref in AVCamCaptureManager.o
  "_AVCaptureDeviceWasConnectedNotification", referenced from:
      -[AVCamCaptureManager init] in AVCamCaptureManager.o
  "_AVCaptureDeviceWasDisconnectedNotification", referenced from:
      -[AVCamCaptureManager init] in AVCamCaptureManager.o
  "_AVMediaTypeAudio", referenced from:
      ___27-[AVCamCaptureManager init]_block_invoke_0 in AVCamCaptureManager.o
      -[AVCamCaptureManager micCount] in AVCamCaptureManager.o
      -[AVCamCaptureManager(InternalUtilityMethods) audioDevice] in AVCamCaptureManager.o
  "_AVMediaTypeVideo", referenced from:
      ___27-[AVCamCaptureManager init]_block_invoke_0 in AVCamCaptureManager.o
      -[AVCamCaptureManager captureStillImage] in AVCamCaptureManager.o
      -[AVCamCaptureManager cameraCount] in AVCamCaptureManager.o
      -[AVCamCaptureManager(InternalUtilityMethods) cameraWithPosition:] in AVCamCaptureManager.o
      -[AVCamViewController(InternalMethods) convertToPointOfInterestFromViewCoordinates:] in AVCamViewController.o
      ___27-[AVCamCaptureManager init]_block_invoke_0 in AVCamCaptureManager.o
      -[AVCamCaptureManager captureStillImage] in AVCamCaptureManager.o
      -[AVCamCaptureManager cameraCount] in AVCamCaptureManager.o
      -[AVCamCaptureManager(InternalUtilityMethods) cameraWithPosition:] in AVCamCaptureManager.o
      -[AVCamViewController(InternalMethods) convertToPointOfInterestFromViewCoordinates:] in AVCamViewController.o
  "_AVVideoCodecJPEG", referenced from:
      -[AVCamCaptureManager setupSession] in AVCamCaptureManager.o
  "_AVVideoCodecKey", referenced from:
      -[AVCamCaptureManager setupSession] in AVCamCaptureManager.o
  "_CMVideoFormatDescriptionGetCleanAperture", referenced from:
      -[AVCamViewController(InternalMethods) convertToPointOfInterestFromViewCoordinates:] in AVCamViewController.o
  "_OBJC_CLASS_$_AVCaptureVideoPreviewLayer", referenced from:
      objc-class-ref in AVCamViewController.o
  "_AVLayerVideoGravityResize", referenced from:
      -[AVCamViewController(InternalMethods) convertToPointOfInterestFromViewCoordinates:] in AVCamViewController.o
  "_AVLayerVideoGravityResizeAspect", referenced from:
      -[AVCamViewController(InternalMethods) convertToPointOfInterestFromViewCoordinates:] in AVCamViewController.o
  "_AVLayerVideoGravityResizeAspectFill", referenced from:
      -[AVCamViewController viewDidLoad] in AVCamViewController.o
      -[AVCamViewController(InternalMethods) convertToPointOfInterestFromViewCoordinates:] in AVCamViewController.o
  "_OBJC_CLASS_$_ALAssetsLibrary", referenced from:
      objc-class-ref in ImageViewController.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)

提前致谢 修改 问题解决了。 应用设置中的一些更改,例如搜索标题路径中的更改等。

3 个答案:

答案 0 :(得分:16)

对我来说:

只需在目标选项卡中将AVFoundation Framework添加到链接的FrameWork和库。

答案 1 :(得分:3)

但对我CoreMedia.frameworkAVFoundation.framework一起帮助。

答案 2 :(得分:0)

请加上。以下框架适用于您的项目并导入目标类

<AssetsLibrary/AssetsLibrary.h>
 <AVFoundation/AVFoundation.h>