在加载 tableview 之前检测 iPhone 方向 [英] Detect iPhone orientation before loading tableview

查看:24
本文介绍了在加载 tableview 之前检测 iPhone 方向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以,我有点困惑......根据这个后,iPhone/iPad的方向是纵向的,直到控制器内部的自动旋转"功能告诉iOS方向已经改变.我的问题是,在我有机会检测到方向的变化之前,似乎 tableview 单元格正在加载.我的 tableview 取决于设备的方向,所以在知道方向之前我无法加载它.有什么我不知道的吗?

So, I'm in a bit of a bind... According to this post, the orientation of the iPhone/iPad is portrait up to a point after which the "auto-rotate" function inside the controller tells iOS that the orientation has changed. My problem is that it appears as though the tableview cells are loading before I have a chance to detect a change in the orientation. My tableview depends on the orientation of the device, so I can't load it until the orientation is known. Is there something I don't know?

谢谢各位!

推荐答案

我相信您正在为应用程序提供对 LAndScape 和 Potrait 模式的支持,因此您应该在 cellForRowAtIndexPath 方法中检测设备方向并为当前方向:

I believe you are providing support for both the LAndScape and Potrait mode for the application so you should detect the device orientation in the cellForRowAtIndexPath method and create the cell for the current orientation:

if ([UIDevice currentDevice].orientation!=UIDeviceOrientationLandscapeLeft && [UIDevice currentDevice].orientation!=UIDeviceOrientationLandscapeRight) {

 Identifier= @"aCell_portrait"

 }else Identifier= @"DocumentOptionIdentifier_Landscape";

这篇关于在加载 tableview 之前检测 iPhone 方向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆