Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I'm trying to present UIImagePickerController as a subview in ordinary UIViewController.

The problem I'm facing is that I'm unable to hide the inner navigation bar (with "Chwile" title and "Anuluj" button). It looks something like this:

iphone screenshot

I tried subclassing UIImagePickerController with my custom controller. I also tried to style the NavigationBar property and achieved the following result:

enter image description here

However, I'd like to remove the Navigation Bar entirely. I tried to call SetNavigationBarHidden(true, true); and NavigationController.SetNavigationBarHidden(true, true); in ViewWillAppear, ViewDidLoad and also ViewDidAppear of custom image picker controller, but with no result.

Do you know how to remove the nav bar entirely? The solution in swift or obj-c is also perfect for me.

    private void PresentImagePicker(UIImagePickerControllerSourceType type)
    {
        imagePicker = new CustomImagePickerController
        {
            SourceType = type,
            AllowsEditing = false,
        };

        imagePicker.FinishedPickingMedia += OnImagePickerFinishedPickingMedia;
        imagePicker.Canceled += OnImagePickerCancelled;

        AddChildViewController(imagePicker);

        ContentView.AddSubview(imagePicker.View);
        imagePicker.View.Frame = Content.Bounds;
        imagePicker.View.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;

        imagePicker.DidMoveToParentViewController(this);
    }
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
292 views
Welcome To Ask or Share your Answers For Others

1 Answer

Instead of adding subview to parent view and managing frames, you can simply use presentViewController like this:

self.present(imagePicker, animated: true, completion: nil)

So, you need to remove following these lines and replace them with just one line as above:

        AddChildViewController(imagePicker);
        ContentView.AddSubview(imagePicker.View);
        imagePicker.View.Frame = Content.Bounds;
        imagePicker.View.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;

        imagePicker.DidMoveToParentViewController(this);

and it will work fine


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...