<legend id='sbEeS'><style id='sbEeS'><dir id='sbEeS'><q id='sbEeS'></q></dir></style></legend>

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

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

        iOS8 - 防止在呈现 viewController 时旋转

        时间:2023-05-18

        1. <tfoot id='liCq1'></tfoot>

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

                <legend id='liCq1'><style id='liCq1'><dir id='liCq1'><q id='liCq1'></q></dir></style></legend>

                    <tbody id='liCq1'></tbody>
                  本文介绍了iOS8 - 防止在呈现 viewController 时旋转的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  我们有一个带有 tableView 的 MainViewController,它提供了一个新的 modalViewController.

                  We have a MainViewController with a tableView, and it presents a new modalViewController.

                  MainViewController 仅限纵向,modalViewController 可以旋转.

                  The MainViewController is restricted to portrait only, and the modalViewController can rotate.

                  问题出在iOS8中,modalViewController旋转时,在MainViewcontroller中调用了iOS8中旋转的回调方法--(void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id)coordinator

                  The problem is in iOS8, that when the modalViewController rotates, the callback method of rotation in iOS8 in MainViewcontroller is called - - (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator

                  因此,UITableView 正在重新加载其数据,这是我们不希望的行为.

                  Thus, the UITableView is getting its data reloaded, which is a behaviour we don't want.

                  我们可以阻止 iOS 8 的这个功能,而不是旋转呈现的 UIViewController 吗?

                  Can we prevent this feature of iOS 8, and not rotate the presenting UIViewController?

                  推荐答案

                  所以经过几天的搜索和调查,我终于想出了一个可能的解决方案.

                  So after long days of searching and investigating, I finally came up with a possible solution.

                  首先,我可以使用导航控制器并推送 viewController 而不是呈现它,但它破坏了我的代码并且不是那么正确.

                  First of all, I can use navigation controller and push the viewController instead of presenting it, but it breaks my code and just isn't so true.

                  我能做的第二件事是不设置约束.我仍然可以使用自动布局,但如果我不设置约束,并设置默认约束,tableView 不会重新加载.当然这也不是很聪明的事情,因为我的 viewController 中有很多元素.

                  The second thing I can do is not setting constraints. I still can use autolayout, but if I don't set constraints, and let the default constraints to be set, the tableView doesn't get reloaded. of course this is also isn't very smart thing to do, as I have many elements in my viewController.

                  最后,我发现我可以在另一个 UIWindow 中显示这个模态"视图控制器.我创建 UIWindow 并将 modalViewController 设置为其 rootViewController.

                  Finally, I figured out that I can show this "modal" viewController in another UIWindow. I create UIWindow and set the modalViewController as its rootViewController.

                  我在 git 中放了一些示例项目:https://github.com/OrenRosen/ModalInWindow

                  I put some example project in git: https://github.com/OrenRosen/ModalInWindow

                  希望对您有所帮助.

                  这篇关于iOS8 - 防止在呈现 viewController 时旋转的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  <small id='1OoSq'></small><noframes id='1OoSq'>

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

                          <legend id='1OoSq'><style id='1OoSq'><dir id='1OoSq'><q id='1OoSq'></q></dir></style></legend>
                            <tbody id='1OoSq'></tbody>