gpt4 book ai didi

ios - 设备旋转后直接开火的方法

转载 作者:行者123 更新时间:2023-12-01 17:55:29 26 4
gpt4 key购买 nike

在我的 iOS 应用程序中,我根据比例设置了所有内容。它根据设备的宽度和高度以编程方式创建我的所有图像。我在网上找到我需要使用的:

- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
duration:(NSTimeInterval)duration

但是,由于我使用屏幕宽度和高度,我需要在它旋转后调用我的重新加载。我应该使用什么功能,比如在旋转发生后触发的这个功能?

最佳答案

来自 iOS 开发者 reference on UIViewController回转:

When a rotation occurs for a visible view controller, the willRotateToInterfaceOrientation:duration:, willAnimateRotationToInterfaceOrientation:duration:, and didRotateFromInterfaceOrientation: methods are called during the rotation. The viewWillLayoutSubviews method is also called after the view is resized and positioned by its parent. If a view controller is not visible when an orientation change occurs, then the rotation methods are never called. However, the viewWillLayoutSubviews method is called when the view becomes visible. Your implementation of this method can call the statusBarOrientation method to determine the device orientation.



所以你得到了你需要的所有信息。使用 viewWillLayoutSubviews或者,如果这对您的目的来说为时已晚,请使用 didRotateFromInterfaceOrientation: .

关于ios - 设备旋转后直接开火的方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18544027/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com