<small id='O5FJ8'></small><noframes id='O5FJ8'>

<legend id='O5FJ8'><style id='O5FJ8'><dir id='O5FJ8'><q id='O5FJ8'></q></dir></style></legend>
    <bdo id='O5FJ8'></bdo><ul id='O5FJ8'></ul>

  1. <i id='O5FJ8'><tr id='O5FJ8'><dt id='O5FJ8'><q id='O5FJ8'><span id='O5FJ8'><b id='O5FJ8'><form id='O5FJ8'><ins id='O5FJ8'></ins><ul id='O5FJ8'></ul><sub id='O5FJ8'></sub></form><legend id='O5FJ8'></legend><bdo id='O5FJ8'><pre id='O5FJ8'><center id='O5FJ8'></center></pre></bdo></b><th id='O5FJ8'></th></span></q></dt></tr></i><div id='O5FJ8'><tfoot id='O5FJ8'></tfoot><dl id='O5FJ8'><fieldset id='O5FJ8'></fieldset></dl></div>
  2. <tfoot id='O5FJ8'></tfoot>

    1. 在 uinavigationcontroller 中转换为横向旋转

      时间:2023-05-17
        <tbody id='130vM'></tbody>

      <tfoot id='130vM'></tfoot>
      <i id='130vM'><tr id='130vM'><dt id='130vM'><q id='130vM'><span id='130vM'><b id='130vM'><form id='130vM'><ins id='130vM'></ins><ul id='130vM'></ul><sub id='130vM'></sub></form><legend id='130vM'></legend><bdo id='130vM'><pre id='130vM'><center id='130vM'></center></pre></bdo></b><th id='130vM'></th></span></q></dt></tr></i><div id='130vM'><tfoot id='130vM'></tfoot><dl id='130vM'><fieldset id='130vM'></fieldset></dl></div>

            <legend id='130vM'><style id='130vM'><dir id='130vM'><q id='130vM'></q></dir></style></legend>

            <small id='130vM'></small><noframes id='130vM'>

            • <bdo id='130vM'></bdo><ul id='130vM'></ul>
              1. 本文介绍了在 uinavigationcontroller 中转换为横向旋转的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                限时送ChatGPT账号..

                我想从 uinaviagtioncontroller 中推送一个横向视图,它的初始视图是纵向的...因此,您单击一个按钮或 tableviewcell,屏幕旋转 90° 进入新视图..

                I want to push a landscape view from within a uinaviagtioncontroller, whose initial view is in portrait... So you click a button, or tableviewcell, and the screen rotates 90° into the new view..

                我将如何管理它?这类似于 Youtube 应用在从电影信息屏幕转换到实际电影时的工作方式.

                How would I manage that? This is similar to how the Youtube app works when transitioning from movie info screen to the actual movie.

                (注意:我对用户拿着设备的旋转方向不感兴趣)

                (note: i am not interested in what rotation the user is holding the device)

                推荐答案

                当从电影信息屏幕转换到实际电影时,YouTube 应用程序中出现的不是导航界面 - 它是一个模态视图.这总是可靠的:如果您以模态方式显示视图(使用 presentModalViewController)并且它只能出现在一个方向上,则应用会旋转到该方向.

                What appears in YouTube app when transitioning from the movie info screen to the actual movie is not navigation interface - it's a modal view. This always works reliably: if you show a view modally (using presentModalViewController) and it can appear in only one orientation, the app rotates to that orientation.

                因此,解决方案是,不要将横向视图推送到导航控制器中;将其呈现为模态视图.

                So, the solution is, don't push your landscape view into the navigation controller; present it as a modal view.

                好的,但也许您想欺骗用户相信我们仍在导航界面中?然后给模态视图一个导航界面,配置成看起来像主导航界面!因此,当您呈现模态视图时,它会向用户显示,就好像导航界面已经旋转(尽管不会有旋转动画).

                Okay, but perhaps you want to fool the user into believing that we are still in the navigation interface? Then give the modal view a navigation interface configured to look like the main navigation interface! So when you present the modal view, it will appear to the user as if the navigation interface has rotated (though there will not be a rotation animation).

                现在,唯一的问题是,如果我们查看它的根视图,模式视图中的导航界面没有返回按钮.这打破了这种错觉(并使用户很难回来).解决方案是一个技巧:将横向视图 两次 推送到导航界面,然后将其呈现为模态视图.这样,导航界面中显示的是堆栈上的 second 视图,因此有一个返回按钮.然后,在导航控制器委托中,当用户尝试返回到您所知道的根级别时,抓住后退按钮并关闭模式视图.所以:

                Now, the only problem is that the navigation interface in the modal view has no Back button if we are looking at its root view. This breaks the illusion (and makes it hard for the user to come back). The solution to that is a trick: push the landscape view twice into the navigation interface before presenting it as a modal view. That way, what is showing in the navigation interface is the second view on the stack, and so there is a Back button. Then, in the navigation controller delegate, catch the Back button and dismiss the modal view when the user tries to return to what you know to be the root level. So:

                - (void) doButton: (id) sender { // appear to navigate into a landscape view
                    SecondViewController* sec = [[SecondViewController alloc] init];
                    sec.title = self.title; // to give the correct Back button title
                    UINavigationController* nav = [[UINavigationController alloc] initWithRootViewController:sec];
                    SecondViewController* sec2 = [[SecondViewController alloc] init];
                    [nav pushViewController:sec2 animated:NO];
                    [self presentModalViewController:nav animated:YES];
                    nav.delegate = self; // so that we know when the user navigates back
                }
                
                // and here's the delegate method
                - (void)navigationController:(UINavigationController *)navigationController 
                      willShowViewController:(UIViewController *)viewController 
                                    animated:(BOOL)animated {
                    if (viewController == [navigationController.viewControllers objectAtIndex:0])
                        [self dismissModalViewControllerAnimated:YES];
                }
                

                这篇关于在 uinavigationcontroller 中转换为横向旋转的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:“开始/结束外观转换的不平衡调用"在带有 Storyboard 的 XCode 4 中以模态方式推送视图时发出 下一篇:如何隐藏“背部"?UINavigationController 中的按钮?

                相关文章

                  <tfoot id='seAJ8'></tfoot>

                1. <small id='seAJ8'></small><noframes id='seAJ8'>

                  <i id='seAJ8'><tr id='seAJ8'><dt id='seAJ8'><q id='seAJ8'><span id='seAJ8'><b id='seAJ8'><form id='seAJ8'><ins id='seAJ8'></ins><ul id='seAJ8'></ul><sub id='seAJ8'></sub></form><legend id='seAJ8'></legend><bdo id='seAJ8'><pre id='seAJ8'><center id='seAJ8'></center></pre></bdo></b><th id='seAJ8'></th></span></q></dt></tr></i><div id='seAJ8'><tfoot id='seAJ8'></tfoot><dl id='seAJ8'><fieldset id='seAJ8'></fieldset></dl></div>
                  <legend id='seAJ8'><style id='seAJ8'><dir id='seAJ8'><q id='seAJ8'></q></dir></style></legend>
                    <bdo id='seAJ8'></bdo><ul id='seAJ8'></ul>