【发布时间】:2012-10-19 12:57:19
【问题描述】:
我正在使用UIImagePickerController 从我的应用程序的 PhotoLibrary 中选择图像。为此,我使用了两种不同的方法。起初我使用了一个类变量UIImagePicker 和下面的代码。
imagepicker = [[UIImagePickerController alloc]init];
imagepicker.delegate = self;
imagepicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
imagepicker.modalTransitionStyle = UIModalTransitionStylePartialCurl;
[self presentModalViewController:self.imagepicker animated:YES];
上面的代码工作正常。但是当我点击按钮时,在这种情况下它需要一些时间来对动画做出反应。然后我用这个方法使用了自动释放池方法
NSAutoreleasePool *pool;
pool = [[NSAutoreleasePool alloc] init];
if([UIImagePickerController isSourceTypeAvailable:
UIImagePickerControllerSourceTypePhotoLibrary])
{
UIImagePickerController *picker= [[[UIImagePickerController alloc]init]autorelease];
picker.delegate = self;
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
picker.modalTransitionStyle = UIModalTransitionStylePartialCurl;
[self presentModalViewController:picker animated:YES];
}
[pool release];
还有魅力。他们都显示分析仪没有泄漏。谁能指出正确的方法。
【问题讨论】: