在 iPhone 中使用相机集成代码时出现内存泄漏

发布于 2024-10-04 06:17:47 字数 693 浏览 1 评论 0原文

我正在开发一个应用程序,允许用户从相机拍照或从库中选择图片。 代码

- (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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

牵强ㄟ 2024-10-11 06:17:47

[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?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文