在-shouldAutorotateToInterfaceOrientation中预测UI元素框架:

Mik*_*ard 6 uinavigationbar uitoolbar autorotate ios

是否可以(在编程时,在运行时)查询导航栏和/或工具栏的高度/厚度将在后旋转?

也就是说,在为特定子视图构建框架时,我想相对于导航栏和工具栏之间的可用空间设置其框架.为了使其平滑,最好是这样做shouldAutorotateToInterfaceOrientation:而不是didRotateFromInterfaceOrientation:,但是self.navigationController.toolbar.frame.size.height方向设备之间的值不同.

我想计算我的新子视图帧对工具栏上的厚度是什么,我想这样做没有如32点,44pt等硬编码值

有什么想法吗?

Val*_*lli 1

你应该调整所有框架的大小willAnimateRotationToInterfaceOrientation:duration:

AFAIK 没有办法预测你的 UIViews 的大小,直到你达到didRotateFromInterfaceOrientation:

一种方法可能是在代码中调整所有框架的大小,包括工具栏。这样您就可以完全控制 UI 元素的大小。