我正在做一个应用程序,允许用户从相机拍照或从库中选择图片。 我正在使用代码
- (BOOL)startCameraPickerFromViewController:(UIViewController*)controller usingDelegate:(id<UIImagePickerControllerDelegate>)delegateObject
{
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
{
UIImagePickerController *picker = [[[UIImagePickerController alloc] init]autorelease];
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
picker.allowsImageEditing = YES;
picker.delegate = self;
[controller presentModalViewController:picker animated:YES];
}
return YES;
}
我正在运行此应用程序时出现内存泄漏。我在3.0上运行这个应用程序。
伙计们请帮助我。
答案 0 :(得分:1)
在[controller presentModalViewController:picker animated:YES];
执行[picker release];
之后,在初始化UIImagePickerController时摆脱自动释放。那可能有用吗?