我在iOS5 ipad上编写应用程序 .
当自定义视图完成加载时,在viewDidLoad上,我调用一个函数,将一个方面设置为某些编程视图,如:
switch (interfaceOrientation)
{
case UIDeviceOrientationPortrait:
{
// Size 3 views using self.view.bounds.size.height
// and self.view.bounds.size.width
break;
}
case UIDeviceOrientationPortraitUpsideDown:
{
// Size 3 views using self.view.bounds.size.height
// and self.view.bounds.size.width
break;
}
case UIDeviceOrientationLandscapeLeft:
{
// Size 3 views using self.view.bounds.size.height
// and self.view.bounds.size.width
break;
}
case UIDeviceOrientationLandscapeRight:
{
// Size 3 views using self.view.bounds.size.height
// and self.view.bounds.size.width
break;
}
default:
break;
}
我在shouldAutorotateToInterfaceOrientation上调用该函数:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
[self setAspect:aspect];
return YES;
}
当我旋转应用程序时,将视图放在正确的位置,但是,当启动应用程序时,如果我在横向上有ipad,它就无法正常工作 . 它需要肖像的大小 . 如果我旋转设备,问题是固定的,但我不喜欢我的应用程序中的问题 .
我不知道为什么会发生这种情况,我已经知道viewdidload上的调用方面太早了 . 我必须在哪里调用setAspect函数?
1 回答
我今天也有同样的问题 .
我最后不得不添加:self.view.autoresizesSubviews = YES;到我的viewDidLoad方法,即使我在Interface Builder中检查了自动调整大小 .