ios 未找到符号:kUTTypeImage
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10144961/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Symbol not found: kUTTypeImage
提问by Lior Pollak
I copied some bits of code from apple's documentation- and I got these 2 errors:
我从苹果的文档中复制了一些代码- 我得到了这两个错误:
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)
What am I doing wrong?
我究竟做错了什么?
EDIT: The code:
编辑:代码:
- (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];
}
I think the error is where the last method starts, but I'm not sure.
我认为错误是最后一个方法开始的地方,但我不确定。
Your post does not have much context to explain the code sections; please explain your scenario more clearly.
您的帖子没有太多上下文来解释代码部分;请更清楚地解释您的场景。
回答by justin
Look up the symbol (kUTTypeImage
) and locate the image/library it should exist in (MobileCoreServices.framework
in this case). Then link your binary with that framework.
查找符号 ( kUTTypeImage
) 并找到它应该存在的图像/库(MobileCoreServices.framework
在本例中)。然后将您的二进制文件与该框架链接起来。
回答by CodeBender
Obligatory Swift answer:
强制性 Swift 答案:
import MobileCoreServices
回答by Sherwin Zadeh
When use with UIDocumentPickerViewController
do:
与UIDocumentPickerViewController
do 一起使用时:
import MobileCoreServices
let type = String(kUTTypeImage)
let documentPickerViewController = UIDocumentPickerViewController(documentTypes: [type], in: .import)