繁体   English   中英

ios如何在使用后关闭UIImagePickerController

[英]ios how dismiss UIImagePickerController after use

我开发了一个从照相机unitl拍摄照片的应用程序,从他的代表那里收到我的解雇后,我解雇了,我收到了exc_bad_access,这是代码:

声明并打开相机:

-(void)ScattaFoto{
 UIImagePickerController *picke = [[UIImagePickerController alloc] init];
   // Delegate is self
   picke.delegate = self;

    // Allow editing of image ?
picke.allowsEditing=NO;


if(TARGET_IPHONE_SIMULATOR) {
      picke.sourceType =  UIImagePickerControllerSourceTypePhotoLibrary;
     }else{
    picke.sourceType =  UIImagePickerControllerSourceTypeCamera;
    }

   // Show image picker
[self presentModalViewController:picke animated:YES];   

}

比委托事件:

- (void) imagePickerController:(UIImagePickerController *)picke   didFinishPickingMediaWithInfo:(NSDictionary *)info
{
// Access the uncropped image from info dictionary
//UIImage *image = [info objectForKey:@"UIImagePickerControllerOriginalImage"];

// [picker release];
[self  dismissModalViewControllerAnimated: YES]; // Here i receive exc_bad_access
[picke release];
}

我穿上.h引用imagePickerControl的委托“ UINavigationControllerDelegate,UIImagePickerControllerDelegate”

有人可以帮我吗?

- (void) imagePickerController:(UIImagePickerController *)picke didFinishPickingMediaWithInfo:(NSDictionary *)info{
    [picke  dismissModalViewControllerAnimated: YES];
}
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo{
       [picker.presentingViewController dismissViewControllerAnimated:YES completion:nil];

}

也许ARC在didFinishPickingMediaWithInfo被调用之前释放了UIImagePickerController吗?

尝试将您的UIImagePickerController放在这样的@property中:

@property (nonatomic, strong) UIImagePickerController *picke;

您可以在此处阅读有关@properties的更多信息。

在使用它之前,您仍然必须分配和初始化UIImagePickerController。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM