2
我對此有點困惑,因爲我已經看到太多不同的變體,並且不確定哪一個是正確的方式。目前,我有:UIImagePickerController的正確發佈
- (IBAction)pickImageFromLibrary:(id)sender
{
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[self presentModalViewController:picker animated:YES];
// [picker release];
}
- (void)imagePickerController:(UIImagePickerController *)picker
didFinishPickingMediaWithInfo:(NSDictionary *)info
{
UIImage *image = [info objectForKey:@"UIImagePickerControllerOriginalImage"];
UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(0.0f, 10.0f, 320.0f, 264.0f)];
self.studyView = imageView;
[imageView release];
[self.tableView setTableHeaderView:studyView];
self.fitImage = [ImageHelper image:image fitInView:studyView];
if (picker.sourceType == UIImagePickerControllerSourceTypeCamera)
{
UIImageWriteToSavedPhotosAlbum(image, self, @selector(image:didFinishSavingWithError:contextInfo:), nil);
}
studyView.image = self.fitImage;
[self dismissModalViewControllerAnimated:YES];
[picker release];
}
我在第一種方法分配UIImagePickerController
,但不會是合乎邏輯的,只在第2個方法,當我關閉它釋放?
很感謝。這意味着我不需要發佈在didFinishPickingMediaWithInfo中:) – 2011-06-06 12:24:04