在我的應用程序中,我有2個視圖,portraitView和landScapeView。而且我的應用程序還包括許多視圖...在橫向和縱向視圖中旋轉的問題
當我啓動應用程序時,橫向和縱向視圖並排顯示。
當我在landscapeview中啓動應用程序時,portraitview正在顯示..later旋轉後返回視圖正在變得適當。
我使用下面給出的代碼......所以,請建議我什麼都改變應該做提到克服以上問題..
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
if (interfaceOrientation == UIInterfaceOrientationLandscapeLeft) {
NSLog(@"LANDSCAPE>>");
portraitView.hidden = YES;
landscapeView.hidden = NO;
UIColor *background = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"bg-ic_landscape.jpg"]];
self.view.backgroundColor = background;
}
else if (interfaceOrientation == UIInterfaceOrientationLandscapeRight){
NSLog(@"LANDSCAPE<<");
portraitView.hidden = YES;
landscapeView.hidden = NO;
UIColor *background = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"bg-ic_landscape.jpg"]];
self.view.backgroundColor = background;
self.view.hidden = NO;
}
else{
portraitView.hidden = NO;
landscapeView.hidden = YES;
NSLog(@"Portrait");
UIColor *background = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"bg-ic.jpg"]];
self.view.backgroundColor = background;
background = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"bg-ic2.jpg"]];
self.view.backgroundColor = background;
}
return YES;
爲什麼要爲風景和肖像製作不同的視圖?爲什麼你沒有相應地根據你所處的方位來固定框架尺寸? –
要更清楚您只需要使用一個視圖。以編程方式或通過適合的界面構建器設置視圖的框架。 – iamsult