您可以通過編程方式來管理方向,並覆蓋willRotateToInterfaceOrientation方法。看到的樣子:
#define IPAD_SIZE_PORTRAIT CGSizeMake(768, 960)
#define IPAD_SIZE_LANDSCAPE CGSizeMake(1024, 704)
-(void)relayoutSubviews:(UIInterfaceOrientation)orientation
{
CGSize scrSize;
if ((orientation == UIInterfaceOrientationLandscapeLeft) || (orientation == UIInterfaceOrientationLandscapeRight))
{
scrSize = IPAD_SIZE_LANDSCAPE;
}
else
{
scrSize = IPAD_SIZE_PORTRAIT;
}
self.view.bounds = CGRectMake(0, 0, scrSize.width, scrSize.height);
self.view.frame = CGRectMake(0, 0, scrSize.width, scrSize.height);
}
-(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
[self relayoutSubviews:toInterfaceOrientation];
}
只是可以肯定,是你的['autoresizingMask'(http://developer.apple.com/library/ios/#documentation/uikit/reference/uiview_class/uiview/uiview。 html#// apple_ref/occ/instp/UIView/autoresizingMask)屬性是否正確設置了標誌'UIViewAutoresizingFlexibleHeight'? – psycho
我使用了'UIWindow * window = [[[UIApplication sharedApplication]委託]窗口]; window.autoresizingMask | = UIViewAutoresizingFlexibleHeight; self.view.autoresizingMask | = UIViewAutoresizingFlexibleHeight;'在viewDidLoad'方法中編譯並旋轉了幾次,高度仍然爲1024 –
嗯..如果您在視圖中添加了標籤或其他東西,縱向模式下的視圖底部,它仍然可以在橫向模式下觀看嗎? (如果是的話,沒有更多的想法:/) – psycho