在 iPhone 中使用相机集成代码时出现内存泄漏
我正在开发一个应用程序,允许用户从相机拍照或从库中选择图片。 代码
- (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 上运行这个应用程序。
伙计们请帮助我。
I'm doing an application which allows user to take a picture from camera or select picture from library.
I'm using the code
- (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;
}
I'm getting memory leak when I'm running this application. I'm running this application on 3.0.
Guys Please help me.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在
[controllerpresentModalViewController:pickeranimated:YES];
之后执行[pickerrelease];
并在初始化 UIImagePickerController 时摆脱自动释放。这可能有效吗?After
[controller presentModalViewController:picker animated:YES];
do[picker release];
and get rid of the autorelease when you init the UIImagePickerController. That may work?