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

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

      • <bdo id='wQiKf'></bdo><ul id='wQiKf'></ul>

      iOS:设备旋转后如何运行函数(Swift)

      iOS: How to run a function after Device has Rotated (Swift)(iOS:设备旋转后如何运行函数(Swift))

      • <legend id='a627z'><style id='a627z'><dir id='a627z'><q id='a627z'></q></dir></style></legend>
        <tfoot id='a627z'></tfoot>

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

            <tbody id='a627z'></tbody>
          <i id='a627z'><tr id='a627z'><dt id='a627z'><q id='a627z'><span id='a627z'><b id='a627z'><form id='a627z'><ins id='a627z'></ins><ul id='a627z'></ul><sub id='a627z'></sub></form><legend id='a627z'></legend><bdo id='a627z'><pre id='a627z'><center id='a627z'></center></pre></bdo></b><th id='a627z'></th></span></q></dt></tr></i><div id='a627z'><tfoot id='a627z'></tfoot><dl id='a627z'><fieldset id='a627z'></fieldset></dl></div>
            • <bdo id='a627z'></bdo><ul id='a627z'></ul>
              • 本文介绍了iOS:设备旋转后如何运行函数(Swift)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                限时送ChatGPT账号..

                我有一个未使用自动布局的 UIView,并且某些组件根据其在主视图中的 X 和 Y 坐标百分比显示.

                I have one UIView which is not using Auto-Layout and some components are displayed based on their percent of X and Y co-ordinates from the main view.

                以前我会运行一个函数来更新他们在 didRotateFromInterfaceOrientation 中的位置,但我发现现在 iOS8 已弃用它.

                Previously I would have run a function to update their positions in didRotateFromInterfaceOrientation however I see this is now deprecated in iOS8.

                我查看了 viewWillTransitionToSize,但它给出了奇怪的结果,而且似乎没有 viewDidtransitionToSize 函数.

                I've taken a look at viewWillTransitionToSize but it's giving weird results, and there doesn't appear to be a viewDidtransitionToSize function.

                有没有简单的方法(在 Swift 中)在设备旋转后运行函数?

                Is there an easy way (in Swift) to run a function after a device rotation?

                推荐答案

                viewWillTransitionToSize 委托方法被调用 UIViewControllerTransitionCoordinator 符合对象.协议声明的方法是 animateAlongsideTransition(_:animation, completion:).您可以使用它在转换完成后执行代码.

                The viewWillTransitionToSize delegate method gets called with a UIViewControllerTransitionCoordinator conforming object. A method that protocol declares is animateAlongsideTransition(_:animation, completion:). You can use that to have code execute after the transition is complete.

                override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
                    super.viewWillTransition(to: size, with: coordinator)
                    coordinator.animate(alongsideTransition: nil) { _ in
                        // Your code here
                    }
                }
                

                这篇关于iOS:设备旋转后如何运行函数(Swift)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                How To Create a Rotating Wheel Control?(如何创建转轮控件?)
                iOS 6 rotations: supportedInterfaceOrientations doesn#180;t work?(iOS 6 旋转:supportedInterfaceOrientations 不起作用?)
                CABasicAnimation rotate returns to original position(CABasicAnimation 旋转返回原始位置)
                How to avoid restarting activity when orientation changes on Android(如何在 Android 上的方向更改时避免重新启动活动)
                UITabBarController Rotation Issues in ios 6(ios 6 中的 UITabBarController 旋转问题)
                How to rotate an image 90 degrees on iOS?(如何在 iOS 上将图像旋转 90 度?)

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

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

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

                        • <bdo id='KRz2b'></bdo><ul id='KRz2b'></ul>