ios - 找不到符号 : kUTTypeImage

标签 ios objective-c linker-errors mobilecoreservices

我从 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];
}

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

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

最佳答案

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

关于ios - 找不到符号 : kUTTypeImage,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10144961/

相关文章:

ios - swift 3 按字典中键的字符串值过滤字典数组

iOS SDK 录制视频而不保存到相册

iOS 应用程序 : Pre-populated large database not allowed - alternatives?

ios - objective-c 中适配器模式的正确实现

c# - 在 monoTouch 中格式化大量数据

ios - 在 iOS 8 和 swift 中更改 UITableViewCell 字体

objective-c - 有没有办法对从 iOS 应用程序导出的 PDF 进行密码保护?

visual-studio-2005 - Visual Studio 2005 中的 LNK 2005 错误

c++ - 将错误与自己的类函数联系起来

使用 Makefile 的 C++ Catch 框架 'multiple definition' 链接器错误