菜鸟教程小白 发表于 2022-12-12 21:44:44

iphone - 在 2 个 ViewController 之间导航


                                            <p><p>我为我的 <code>ViewControllers</code> 使用 <code>Navigation Controller</code>,我将我的 <code>importantViewController</code> 设置为它的 <code>RootView</code>:</p>

<pre><code>UINavigationController *navControl = [ initWithRootViewController: vc];
;
</code></pre>

<p>然后,我 pushView anotherView 的 <code>FrontViewController</code> 像这样:</p>

<pre><code>    ;
</code></pre>

<p>在 <code>FrontViewController</code> 中按下按钮后,将推送另一个 View<code>ViewA</code> 但它与另一个 ViewController <code>ViewB</code> 连接方式与此相同再次:</p>

<pre><code>    ;
</code></pre>

<p>(我认为我在使用 <code>;</code> 解雇其中任何一个时做错了)</p>

<p>这是一个插图:</p>

<p> <img src="/image/Kreba.png" alt="enter image description here"/> </p>

<p>我的问题是,我需要在 ViewA 和 ViewB 之间导航,然后当我关闭其中任何一个时,它会返回到 <code>FrontViewController</code>。就像一个 childView 的 child 。谢谢。</p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>我认为这是 <strong>dismissModalViewController</strong>,但试试这个,</p>

<p>从 ViewB 编写这样的代码</p>

<pre><code>[.navigationController popViewControllerAnimated:YES];
</code></pre>

<p>从 ViewA 你可以写,</p>

<pre><code>;
</code></pre>

<p>或者你可以使用这个,</p>

<pre><code>;
</code></pre>

<p><strong>更新</strong></p>

<pre><code>for (UIViewController *tmpControllerin )
{
    if (])
    {
      ;
      break;
    }
}
</code></pre>

<p>这是实现这一目标的最佳解决方案。</p>

<p>在您的 ViewA 或 B 上编写此代码。</p>

<p>希望它现在可以工作:-)</p></p>
                                   
                                                <p style="font-size: 20px;">关于iphone - 在 2 个 ViewController 之间导航,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/11290360/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/11290360/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: iphone - 在 2 个 ViewController 之间导航