菜鸟教程小白 发表于 2022-12-13 17:02:08

ios - UIImagePickerController 弹出后 UINavigationBar 消失


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

<p>显示导航栏。</p>

<p> <a href="/image/l6NgD.png" rel="noreferrer noopener nofollow"><img src="/image/l6NgD.png" alt="Start"/></a> </p>

<p>这是 <code>UIImagePickerController</code>View ,它看起来好像 CANCEL 按钮位于 <code>NavigationBar</code> 下方。 (在这张照片中很难看到。)</p>

<p> <a href="/image/2ZwIA.png" rel="noreferrer noopener nofollow"><img src="/image/2ZwIA.png" alt="enter image description here"/></a> </p>

<p><code>UIImagePickerController</code> 弹出并重新加载 View 后,<code>NavigationBar</code> 消失了。 </p>

<p> <a href="/image/sLDBy.png" rel="noreferrer noopener nofollow"><img src="/image/sLDBy.png" alt="enter image description here"/></a> </p>

<p>这是我如何调用 <code>UIImagePickerController</code>。我继承自 <code>UIImagePickerControllerDelegate</code></p>

<p> <a href="/image/6TwbP.png" rel="noreferrer noopener nofollow"><img src="/image/6TwbP.png" alt="enter image description here"/></a> </p>

<pre><code> UIImagePickerController *imagePickerController = [ init];
    imagePickerController.modalPresentationStyle = UIModalPresentationCurrentContext;
    imagePickerController.sourceType = sourceType;
    imagePickerController.delegate = self;

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

    self.imagePickerController = imagePickerController;
    ;
</code></pre>

<p>虽然代表说不兼容。</p>

<p> <a href="/image/p6Jur.png" rel="noreferrer noopener nofollow"><img src="/image/p6Jur.png" alt="enter image description here"/></a>
<a href="/image/W0Wff.png" rel="noreferrer noopener nofollow"><img src="/image/W0Wff.png" alt="enter image description here"/></a> </p>

<p>如何纠正问题?</p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>我加了</p>

<pre><code>imagePickerController.modalPresentationStyle = UIModalPresentationFullScreen;
imagePickerController.modalTransitionStyle   = UIModalTransitionStyleCoverVertical;
</code></pre>

<p>这似乎把 imagePickerController 放在了当前 View 的顶部。</p></p>
                                   
                                                <p style="font-size: 20px;">关于ios - UIImagePickerController 弹出后 UINavigationBar 消失,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/37999095/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/37999095/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios - UIImagePickerController 弹出后 UINavigationBar 消失