1
我試圖在iOS中加載圖片選擇器,它在第一次嘗試中正常工作,但是當我第二次執行此操作時我有以下警告警告:嘗試在<MFSideMenuContainerViewController>上呈現其視圖不在窗口層次結構中的<UIImagePickerController>
警告:嘗試呈現其視圖不在窗口層次結構中!
我採摘圖像代碼如下
[self startCameraControllerFromViewController:self usingDelegate:self sourceType:UIImagePickerControllerSourceTypePhotoLibrary];
和方法如下startCameraControllerFromViewController
- (BOOL) startCameraControllerFromViewController: (UIView*) controller usingDelegate: (id) delegate sourceType:(UIImagePickerControllerSourceType) sourceType{
if (([UIImagePickerController isSourceTypeAvailable:
sourceType] == NO)
|| (delegate == nil)
|| (controller == nil))
{
DLog(@"no is being returned");
return NO;
}
if(_delegate != nil &&[ _delegate respondsToSelector:@selector(imagePickerOpened)]){
[_delegate imagePickerOpened];
}
if(cameraUI==nil){
// [SVProgressHUD showWithStatus:@"Loading"];
[ALERT showLoader];
dispatch_queue_t concurrentQueue=dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
dispatch_async(concurrentQueue, ^{
cameraUI = [[UIImagePickerController alloc] init];
cameraUI.sourceType = sourceType;
cameraUI.mediaTypes=cameraUI.mediaTypes = [[NSArray alloc] initWithObjects: (NSString *) kUTTypeImage, nil];
cameraUI.allowsEditing = YES;
cameraUI.delegate = delegate;
dispatch_async(dispatch_get_main_queue(), ^{
[self.window.rootViewController presentModalViewController:cameraUI animated:YES];
//[self presentModalViewController:cameraUI animated:YES ];
[ALERT hideLoader];
});
});
}
else{
cameraUI.sourceType = sourceType;
[self.window.rootViewController presentModalViewController:cameraUI animated:YES];
//[self presentModalViewController:cameraUI animated:YES ];
}
return YES;
}
我不明白你是怎麼解決這個問題的?我遇到類似的代碼 –
我的代碼是相當大的問題,所以不能發佈我的整個代碼。只是看看你的根視圖控制器是什麼,並且是相同的根視圖控制器,目前我相信他們會不同。 –