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

标签 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)

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

最佳答案

对我来说:

只需将 AVFoundation Framework 添加到“目标”选项卡中的“链接框架”和“库”即可。

关于iphone - 在ios5中访问相机 View 并捕获图像使用哪个框架?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9800450/

相关文章:

iphone - 从 Nib 加载 View 不会初始化 socket - Monotouch

objective-c - 如果 View Controller 转换完成得太快,应用程序会崩溃

swift - 目前不支持多个音频/视频 AVCaptureInputs

ios - 在 iOS 中无法使用 avfoundation 播放特定的 MP4 文件

ios - 为什么视频输出始终为 30 fps,尽管它设置为其他方式?

ios - 此 bundle 无效。提交到应用商店的新应用和应用更新必须使用 xcode 5 和 ios 7 sdk 构建

iphone - 在 cocos2d 中添加 UIViewController

iphone - 如何在 iPhone 中使用异步 Web 服务调用自动完成 TextField?

xcode - iOS : NSXMLParser get attribute

iphone - 在 iOS 的 tableView 中向上滚动时(当单元格消失时)Exc_bad_access