问题描述
限时送ChatGPT账号..我正在尝试将 UIImagePickerController 作为普通 UIViewController 中的子视图呈现.
I'm trying to present UIImagePickerController as a subview in ordinary UIViewController.
我面临的问题是我无法隐藏内部导航栏(带有Chwile"标题和Anuluj"按钮).它看起来像这样:
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:
我尝试用我的自定义控制器子类化 UIImagePickerController.我还尝试设置 NavigationBar 属性的样式并获得以下结果:
I tried subclassing UIImagePickerController with my custom controller. I also tried to style the NavigationBar property and achieved the following result:
但是,我想完全删除导航栏.我试图在 ViewWillAppear
、ViewDidLoad<中调用
SetNavigationBarHidden(true, true);
和 NavigationController.SetNavigationBarHidden(true, true);
/code> 和自定义图像选择器控制器的 ViewDidAppear
,但没有结果.
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.
您知道如何完全删除导航栏吗?swift 或 obj-c 中的解决方案对我来说也很完美.
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);
}
推荐答案
您可以像这样简单地使用presentViewController,而不是将子视图添加到父视图和管理框架:
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);
它会正常工作
这篇关于如何在嵌入式 UIImagePickerController 中隐藏导航栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
更多推荐
[db:关键词]
发布评论