2011-11-29 56 views
0

捕獲圖像後,發生回調但發生錯誤,因爲它沒有關閉相機視圖。我的代碼非常簡單,我唯一的疑問是我使用了一個標籤欄控制器,並在其中一個選項卡中推送了imagePicker,只是一個想法。dismissModalViewControllerAnimated:不關閉模式視圖

- (IBAction)imageButtonPressed:(id)sender { 
    UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init]; 
    imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera; 
    imagePicker.delegate = self; 
    imagePicker.allowsEditing = YES; 
    [self presentModalViewController:imagePicker animated:YES]; 
} 



- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { 
    [self dismissModalViewControllerAnimated:YES]; 
    self.portaitImage.image = [info objectForKey:UIImagePickerControllerOriginalImage]; 
} 

回答

2

您需要解僱的UIImagePickerController,不self

[picker dismissModalViewControllerAnimated:YES]; 
+0

是的,你是對的,但不符合邏輯的,我所以我在想,當前對象提出的模態視圖,其職責應駁回它不是推視圖本身。無論如何,它的工作現在感謝。 – Gladmir