получить доступ к просмотру камеры и захватить изображение в ios5, какой фреймворк используется? - PullRequest
2 голосов
/ 21 марта 2012

До того, как ios 5 AVFoundationFramework используется, но он не работает с раскадровкой ios5 Приложение выдает ошибки связывания, например, даже если я добавляю фреймворк. Пожалуйста, помогите мне.

  - (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 ]

16 голосов
/ 03 апреля 2012

Мне:

Просто добавьте AVFoundation Framework в Linked FrameWork и библиотеки на вкладке Target.

3 голосов
/ 22 марта 2013

Но для меня CoreMedia.framework вместе с AVFoundation.framework помогло.

0 голосов
/ 04 октября 2013

пожалуйста, добавьте.следующий фрейм работает в вашем проекте и импортируется в целевой класс

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