在iOS中,iPad的定位不仅仅是四个
现在我意识到,当我只为iPad版本编写应用程序时 我的iPad iOS版本是iOS在iOS中,iPad的定位不仅仅是四个,ipad,cocoa-touch,ios5,orientation,uitextview,Ipad,Cocoa Touch,Ios5,Orientation,Uitextview,现在我意识到,当我只为iPad版本编写应用程序时 我的iPad iOS版本是iOS5.1 是的,在加载数据之前,我需要检查iPad的方向 因此,我检查以下代码 if (UIDeviceOrientationIsLandscape([UIDevice currentDevice].orientation)) { self.originalLandScape = CGRectMake(0, 48, 1024, 704); self.originalPortra
5.1
是的,在加载数据之前,我需要检查iPad的方向
因此,我检查以下代码
if (UIDeviceOrientationIsLandscape([UIDevice currentDevice].orientation))
{
self.originalLandScape = CGRectMake(0, 48, 1024, 704);
self.originalPortrait = CGRectMake(0, 48, 768, 960);
self.txtView.frame = self.originalLandScape;
}
else
{
self.originalPortrait = CGRectMake(0, 48, 768, 960);
self.originalLandScape = CGRectMake(0, 48, 1024, 704);
self.txtView.frame = self.originalPortrait;
}
因为我需要将固定大小设置为我的UITextView
然而,我意识到,当我的iPad带有横向布局并水平放置在地板上时,设置UITextView
大小是不正确的
但当我从地板上拿着iPad,手里拿着scape
就像看书一样,我上面的代码就是工作
这两者有什么不同吗
我不知道怎么解决它
谢谢你的建议和帮助。你是对的-iPad的方向不仅仅是四个,而是六个:
UIDeviceOrientationLandscapeLeft
UIDeviceOrientationLandscapeRight
UIDeviceOrientationPortrait
UIDeviceOrientationPortraitUpsideDown
UIDeviceOrientationFaceUp
UIDeviceOrientationFaceDown
因此,您的else
子句不仅适用于纵向,也适用于面朝上和面朝下
我怀疑您实际上想要使用的是界面方向。这可能与设备方向相同,也可能与设备方向不同(取决于应用程序支持的方向),但如果您希望为特定方向正确绘制UI元素,则重要的是界面其余部分的方向,而不是设备方向
只有四种界面方向:
UIInterfaceOrientationLandscapeLeft
UIInterfaceOrientationLandscapeRight
UIInterfaceOrientationPortrait
UIInterfaceOrientationPortraitUpsideDown
您可以使用UIViewController属性interfaceOrientation
获取这些属性,并使用UIKit函数UIInterfaceOrientationIsLandscape()
和UIInterfaceOrientationIsortRait()
在你的代码中试试这个
if(UIInterfaceOrientationIsLandscape(self.interfaceOrientation))) {
...
} else {
...
}