【问题标题】:UINavigationBar disappears after UIImagePickerController is poppedUIImagePickerController 弹出后 UINavigationBar 消失
【发布时间】:2016-10-26 05:29:52
【问题描述】:

我有嵌入在 UITabBarController 中的 UIViewController。在我的PhotoViewController 上,用户可以选择添加照片并调用UIImagePickerController。用户选择照片并弹出视图后,导航栏消失。

显示导航栏。

这是UIImagePickerController 视图,看起来好像取消按钮在NavigationBar 下方。 (在这张照片中很难看到。)

UIImagePickerController 弹出并重新加载视图后,NavigationBar 消失了。

这就是我如何称呼UIImagePickerController。我继承自UIImagePickerControllerDelegate

 UIImagePickerController *imagePickerController = [[UIImagePickerController alloc] init];
    imagePickerController.modalPresentationStyle = UIModalPresentationCurrentContext;
    imagePickerController.sourceType = sourceType;
    imagePickerController.delegate = self;

    if (sourceType == UIImagePickerControllerSourceTypeCamera) {
        imagePickerController.showsCameraControls = YES;
    }

    self.imagePickerController = imagePickerController;
    [self presentViewController:self.imagePickerController animated:YES completion:nil];

虽然代表说不兼容。

如何纠正问题?

【问题讨论】:

    标签: ios uinavigationcontroller uinavigationbar uiimagepickercontroller


    【解决方案1】:

    我加了

    imagePickerController.modalPresentationStyle = UIModalPresentationFullScreen;
    imagePickerController.modalTransitionStyle   = UIModalTransitionStyleCoverVertical;
    

    这似乎把 imagePickerController 放在了当前视图的顶部。

    【讨论】:

      【解决方案2】:

      经过几个小时的搜索,我没有找到合适的解决方案。问题是我将导航栏隐藏在显示图像选择器的视图中,但是当我这样做时:

      imagePicker.setNavigationBarHidden(false, animated: false)
      

      在显示present() 之前问题仍然出现,但是当我在dismiss() 之后每次都这样做时,它可以正常工作......就像这样:

      imagePicker.dismiss(animated: true)
      imagePicker.setNavigationBarHidden(false, animated: false)
      

      我不知道它为什么会这样工作,但可能对某人有帮助。如果有人有答案,请解释一下。

      【讨论】:

        猜你喜欢
        • 2011-06-09
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-10-27
        相关资源
        最近更新 更多