ios - 在窗口层次结构中,ios警告:尝试在 <MFSideMenuContainerViewController> 上显示它的视图不存在的<UIImagePickerController>

  显示原文与译文双语对照的内容

我在试图在iOS中加载图片选择器,它在第一次尝试时很好,但是第二次它会给我以下警告。

警告:试图显示谁的视图不在窗口层次结构中 !

我的挑选图像的代码如下


[self startCameraControllerFromViewController:self usingDelegate:self sourceType:UIImagePickerControllerSourceTypePhotoLibrary];



方法如下所示


- (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;



}

时间: 原作者:

这个问题与设置 root 视图控制器i 设置 root 视图控制器that我将当前视图控制器设置为 root 视图控制器,并修正了问题。

...