我試圖在從圖像選取器中選取圖像後創建模式視圖控制器。我使用的代碼:iOS:警告:試圖在演示文稿正在進行時在<ViewController>上呈現<ModalViewController>
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
NSLog(@"Picker has returned");
[self dismissModalViewControllerAnimated:YES];
// TODO: make this all threaded?
// crop the image to the bounds provided
img = [info objectForKey:UIImagePickerControllerOriginalImage];
NSLog(@"orig image size: %@", [[NSValue valueWithCGSize:img.size] description]);
// save the image, only if it's a newly taken image:
if([picker sourceType] == UIImagePickerControllerSourceTypeCamera){
UIImageWriteToSavedPhotosAlbum(img, nil, nil, nil);
}
// self.image_View.image=img;
//self.image_View.contentMode = UIViewContentModeScaleAspectFit;
ModalViewController *sampleView = [[ModalViewController alloc] init];
[self presentModalViewController:sampleView animated:YES];
}
不過,我收到警告:
Warning: Attempt to present <ModalViewController: 0x7561600> on <ViewController: 0x75a72e0> while a presentation is in progress!
和模態視圖不出現。
我在做什麼錯?
**完整的解決方案HERE **,約翰的回答是:http://stackoverflow.com/questions/14453001/meaning-of-warning-while-演示進行中 – Fattie