【问题标题】:DismissViewControllerAnimated not working with navigationDismissViewControllerAnimated 不适用于导航
【发布时间】:2013-05-16 08:51:16
【问题描述】:

在我的应用程序中,我在关闭已推送到新视图的视图后使用以下代码实现,当我尝试实现视图时,视图并没有关闭而是重叠。这是我的代码,

-(IBAction)selectExitingPicture
 {
if([UIImagePickerController isSourceTypeAvailable:
    UIImagePickerControllerSourceTypePhotoLibrary])
   {
    UIImagePickerController *picker= [[UIImagePickerController alloc]init];
    picker.delegate = self;
    picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
    [self presentViewController:picker animated:YES completion:nil];
   }
 }
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image
             editingInfo:(NSDictionary *)editingInfo
 {
    [picker dismissViewControllerAnimated:YES completion:^{
    cropingImageViewCon = [[CropingImageViewControl alloc]initWithNibName:@"CropingImageView" bundle:nil];
    cropingImageViewCon.delegate = self;
    cropingImageViewCon.originalImg = image;
    [self.navigationController presentModalViewController:cropingImageViewCon animated:YES];
    }];
  }

我的代码有什么问题,请任何人帮忙。

【问题讨论】:

  • 一开始你是如何展示选择器的?
  • @MikePollard 我已经更新了任务代码。请检查
  • 您期望什么视图应该被忽略?查看代码,应该关闭 imagepicker 视图,之后应该在具有调用 selectExitingPicture 的控件的视图上模态显示croppingImageViewCon 视图
  • 关闭 ImagePicker 后是否要推入 CropingImageViewControl?
  • @Marcel 当我这样做时它显示Attempt to present <View2: 0x817a7d0> on <UINavigationController: 0x81721a0> whose view is not in the window hierarchy!

标签: ios uinavigationcontroller presentmodalviewcontroller


【解决方案1】:

如果你想推入CropingImageViewControl,那你就走错路了,

使用

[self.navigationController pushViewController:yourViewCotrollerObject animated:YES];

而不是使用presentModalViewController:

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-02-05
    • 2019-08-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多