简体   繁体   English

iPhone设备4s,5、5s和6的Today小部件中未检测到设备方向

[英]Device orientation not detecting in Today widget for iPhone device 4s,5,5s and 6

I am using below code to check orientation of device in today widget code base but when I change mode to landscape for device iPhone 4s, 5, 5s and 6 then below code won't work. 我正在使用下面的代码在今天的小部件代码库中检查设备的方向,但是当我将设备iPhone 4s,5、5s和6的模式更改为横向时,下面的代码将不起作用。

let orientationSize: CGSize = UIScreen.mainScreen().bounds.size if (orientationSize.width / orientationSize.height > 1) { numberOfEvents = isiPad ? 让directionSize:CGSize = UIScreen.mainScreen()。bounds.size if(orientationSize.width /directionSize.height> 1){numberOfEvents = isiPad? ipadLandscapeModeNumberOfEvents : iphoneLandscapeModeNumberOfEvents } ipadLandscapeModeNumberOfEvents:iphoneLandscapeModeNumberOfEvents}

I have tried below methods and all are won't work 我尝试了以下方法,但都无法使用

  • override fun viewWillTransitionToSize 覆盖有趣的viewWillTransitionToSize
  • override fun willRotateToInterfaceOrientation 覆盖乐趣willRotateToInterfaceOrientation

I am stuck in this long time. 我被困在这么长的时间。

Please note that issue is only for iPhone 4s,5,5s and 6. 请注意,该问题仅适用于iPhone 4s,5、5s和6。

约束1 在此处输入图片说明

You are looking at the bounds (size) before the orientation change within: 您正在查看方向更改之前的边界(大小):

willRotateToInterfaceOrientation

so that will show you current size before orientation actually changes. 这样可以在实际更改方向之前向您显示当前尺寸。 I suggest you to check the size with 我建议你用

CGSize = UIScreen.mainScreen().bounds.size

within following method: 在以下方法内:

didRotateFromInterfaceOrientation

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM