Ich habe einige Code-Teile aus der Apple-Dokumentation kopiert - und diese 2 Fehler erhalten:
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)
Was mache ich falsch?
EDIT: Der 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];
}
Ich denke, der Fehler ist, wo die letzte Methode beginnt, aber ich bin nicht sicher.
Ihr Beitrag hat nicht viel Kontext, um die Codeabschnitte zu erklären. Bitte erläutern Sie Ihr Szenario klarer.
UIImagePickerController
, sprechen sie über die VerwendungkUT*
fürmediaTypes
, aber in ihrem Beispielcode, sie oft passieren nur die Werte von einer Funktion zum Array. Sie verwenden es nie in ihrem Code und erwähnen nicht, dass Sie es importieren müssen.