未找到符号:kUTTypeImage

Posted

技术标签:

【中文标题】未找到符号:kUTTypeImage【英文标题】:Symbol not found: kUTTypeImage 【发布时间】:2012-04-26 01:28:29 【问题描述】:

我从apple's documentation-复制了一些代码,我得到了这两个错误:

Undefined symbols for architecture i386:
  "_kUTTypeImage", referenced from:
      -[ImagePicker imagePickerController:didFinishPickingMediaWithInfo:] in ImagePicker.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)

我做错了什么?

编辑: 代码:

- (IBAction) showSavedMediaBrowser 
    [self startMediaBrowserFromViewController: self
                                usingDelegate: (id)self];


- (BOOL) startMediaBrowserFromViewController: (UIViewController*) controller
                               usingDelegate: (id <UIImagePickerControllerDelegate,
                                               UINavigationControllerDelegate>) delegate 

    if (([UIImagePickerController isSourceTypeAvailable:
          UIImagePickerControllerSourceTypeSavedPhotosAlbum] == NO)
        || (delegate == nil)
        || (controller == nil))
        return NO;

    UIImagePickerController *mediaUI = [[UIImagePickerController alloc] init];
    mediaUI.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;

    // Displays saved pictures and movies, if both are available, from the
    // Camera Roll album.
    mediaUI.mediaTypes =
    [UIImagePickerController availableMediaTypesForSourceType:
     UIImagePickerControllerSourceTypeSavedPhotosAlbum];

    // Hides the controls for moving & scaling pictures, or for
    // trimming movies. To instead show the controls, use YES.
    mediaUI.allowsEditing = YES;

    mediaUI.delegate = delegate;

    [controller presentViewController:mediaUI animated:YES completion:nil];
    return YES;


- (void) imagePickerController: (UIImagePickerController *) picker
 didFinishPickingMediaWithInfo: (NSDictionary *) info 

    NSString *mediaType = [info objectForKey: UIImagePickerControllerMediaType];
    UIImage *originalImage, *editedImage, *imageToUse;

    // Handle a still image picked from a photo album
    if (CFStringCompare ((__bridge_retained CFStringRef) mediaType, kUTTypeImage, 0)
        == kCFCompareEqualTo) 

        editedImage = (UIImage *) [info objectForKey:
                                   UIImagePickerControllerEditedImage];
        originalImage = (UIImage *) [info objectForKey:
                                     UIImagePickerControllerOriginalImage];

        if (editedImage) 
            imageToUse = editedImage;
         else 
            imageToUse = originalImage;
        
        // Do something with imageToUse
    

    [[picker parentViewController] dismissModalViewControllerAnimated: YES];

我认为错误是最后一个方法开始的地方,但我不确定。

您的帖子没有太多上下文来解释代码部分;请更清楚地解释您的情况。

【问题讨论】:

(这不是你的错)我已经阅读了我在UIImagePickerController 上找到的所有文档,他们谈到使用kUT* 代替mediaTypes,但在他们的示例代码中,他们通常只是将值从一个函数传递到数组。他们从未在代码中实际使用过它,也没有提到您需要导入它。 【参考方案1】:

查找符号 (kUTTypeImage) 并找到它应该存在的图像/库(在本例中为 MobileCoreServices.framework)。然后将您的二进制文件与该框架链接。

【讨论】:

另外不要忘记导入标头 成功了!显然我链接的是 CoreFoundation 而不是 MobileCoreServices。 或者把@import MobileCoreServices;如果您不想导入框架并做所有讨厌的工作【参考方案2】:

必填的 Swift 答案:

import MobileCoreServices

【讨论】:

【参考方案3】:

当与UIDocumentPickerViewController 一起使用时:

import MobileCoreServices

let type = String(kUTTypeImage)
let documentPickerViewController = UIDocumentPickerViewController(documentTypes: [type], in: .import)

【讨论】:

【参考方案4】:

对于 Swift,它似乎在

import UniformTypeIdentifiers

let type = String(describing: UTType.image)

【讨论】:

以上是关于未找到符号:kUTTypeImage的主要内容,如果未能解决你的问题,请参考以下文章

未找到 QQmlEngine 符号

Linux:性能最高,未找到内核符号

X11。未找到符号:_CGLGetCurrentContext

Android Studio 附加到进程未找到本机符号

GDB - 未找到调试符号 -

PyCuda - 使用 *.cubin - 未找到命名符号