我已经设置了一些功能。但我不知道从这里去哪里。一旦我知道如何实际使用图像,我可能会弄清楚如何处理 facebook。我尝试将图像保存到 NSDictionary 中,然后重定向到不同的视图控制器,但它不允许我从 imagePickerController 方法中重定向。所以有人知道如何使用从相机胶卷中选择的图像吗?
我的下一个想法是将它保存在 NSDictionary 中,然后只用一个语句检查 NSdictionary 的值是否发生了变化,但这根本不是一种有效的方法。
在下面编辑以包括提供的答案,但没有任何反应,没有图像显示或任何东西。我错过了什么?
- (void) useCameraRoll
{
if ([UIImagePickerController isSourceTypeAvailable:
UIImagePickerControllerSourceTypeSavedPhotosAlbum])
{
UIImagePickerController *imagePicker =
[[UIImagePickerController alloc] init];
imagePicker.delegate = self;
imagePicker.sourceType =
UIImagePickerControllerSourceTypePhotoLibrary;
imagePicker.mediaTypes = [NSArray arrayWithObjects:
(NSString *) kUTTypeImage,
nil];
imagePicker.allowsEditing = NO;
[self presentModalViewController:imagePicker animated:YES];
[imagePicker release];
newMedia = NO;
}
}
-(void)imagePickerController:(UIImagePickerController *)picker
didFinishPickingMediaWithInfo:(NSDictionary *)info
{
NSString *mediaType = [info
objectForKey:UIImagePickerControllerMediaType];
[self dismissModalViewControllerAnimated:YES];
if ([mediaType isEqualToString:(NSString *)kUTTypeImage]) {
UIImage *image = [info
objectForKey:UIImagePickerControllerOriginalImage];
NSLog(@"image:%@",image);
displayPhoto.image = image;
[displayPhoto setFrame:CGRectMake(0, 0, 320, 480)];
[[self view] addSubview:displayPhoto];
}
else if ([mediaType isEqualToString:(NSString *)kUTTypeMovie])
{
// Code here to support video if enabled
}
}