gpt4 book ai didi

iphone - AppDelegate 中的 DeviceOrientation 检查

转载 作者:太空狗 更新时间:2023-10-30 03:48:28 24 4
gpt4 key购买 nike

我在 AppDelegate 中创建了一个 View ,我像这样添加到窗口中:

[window addSubview:myView];
我希望每次返回此 View 时都能检查设备方向,因此我可以对其进行一些修改。我怎样才能在 appDelegate 中做到这一点?

最佳答案

您可以在委托(delegate)中实现这些方法之一以查看应用程序何时旋转:

- (void)application:(UIApplication *)application willChangeStatusBarOrientation:(UIInterfaceOrientation)newStatusBarOrientation duration:(NSTimeInterval)duration;
- (void)application:(UIApplication *)application didChangeStatusBarOrientation:(UIInterfaceOrientation)oldStatusBarOrientation;

或者根据需要检查 UIApplication 状态栏的方向:

[[UIApplication sharedApplication] statusBarOrientation];

设备方向(可能与界面方向匹配也可能不匹配)是:

[[UIDevice currentDevice] orientation];

关于iphone - AppDelegate 中的 DeviceOrientation 检查,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2831581/

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