簡體   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