2011-02-08 5 views
0

내 응용 프로그램은 내비게이션 기반입니다.iPhone 장치 방향 문제

모든보기는 보고서 모드를 제외한 세로 모드를 표시합니다. 보고서 모드는 가로 회전 할 때 가로 모드를 표시합니다.

장치가 가로 모드로 회전하는 경우 보고서보기에 가로 모드가 표시됩니다. 보고서가 가로 모드 인 경우 장치 세로 모드에서 다시 회전하면 현재보기의 일반보기가 표시됩니다.

현재 작업의 흐름 내보기 표시. 현재보기에서 세로보기 모드이고 가로 모드에서 장치를 회전하므로 보고서 모드의 가로 모드가 표시됩니다. 두 회전 후 세로 모드에서 현재보기지고있다. 견인 회전을 줄여야합니다. 제발 나를 안내 해줘. 다시 한번 회전하면 보고서의 가로 모드에 대한 조건을 확인하는 방법은 세로보기 모드에서 현재보기를 표시해야합니다.

Here at ReportViewController 


- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 

    return UIInterfaceOrientationIsLandscape(interfaceOrientation); 

} 

@interface CurrentViewController 

BOOL isShowingLandscapeView; 
Report *landscapeViewController; 

@implementation CurrentViewController 


- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 

    Report *viewController = [[Report alloc]initWithNibName:@"Report" bundle:nil]; 
    self.landscapeViewController = viewController; 
    [viewController release]; 

    [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications]; 
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(orientationChanged:) 
               name:UIDeviceOrientationDidChangeNotification object:nil]; 
} 

- (void)orientationChanged:(NSNotification *)notification 
{ 

    [self performSelector:@selector(updateLandscapeView) withObject:nil afterDelay:0]; 
} 


- (void)updateLandscapeView 
{ 
    UIDeviceOrientation deviceOrientation = [UIDevice currentDevice].orientation; 

    if (UIDeviceOrientationIsLandscape(deviceOrientation) && !isShowingLandscapeView) 
    { 

     [self presentModalViewController:self.landscapeViewController animated:YES]; 
     isShowingLandscapeView = YES; 

    } 
    else if(deviceOrientation == UIInterfaceOrientationPortrait && isShowingLandscapeView) 
    { 
     [self dismissModalViewControllerAnimated:YES]; 
     isShowingLandscapeView = NO; 
    }  
} 



- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
    return (interfaceOrientation == UIInterfaceOrientationPortrait); // support only portrait 

} 

답변

0

질문을 이해할 수 있는지 모르겠지만 논리가 바뀌었을 수 있습니다. ReportViewController에서 ,

- (BOOL)shouldAutorotateToInterfaceOrientation 

가 회전하기 전에라고, 그래서 반환 YES 초상화에 대 한 및 NO,하지 (가로을위한 NO 반환 (예,보기가 가로 세로로 회전 할 수 있도록)한다 보기가 풍경에서 풍경으로 회전하도록 허용).

와 유사 CurrentVC에서

- 도움

return (interfaceOriention==UIInterfaceOrientationLandscape); 

희망을 시도합니다. -Mike

+0

반환 할 수 없습니다 (interfaceOriention == UIInterfaceOrientationLandscape); UIInterfaceOrientationLandscape에 대한 검사 조건이 없습니다. 가능한 왼쪽 또는 오른쪽 및 Islandscape. updateLandscapeView 메서드 가로보기로 세로보기 (UIDeviceOrientationIsPortrait (deviceOrientation) &&! isShowingLandscapeView) 현재보기를 세로로 설정하고 장치를 회전합니다. 현재보기가 가로로 회전하고 보고서보기가 가로 방향이고 현재보기가 세로로 회전됩니다. 현재가 필요합니다. 현재 회전 장치 보고서보기가 가로 방향이고 현재보기가 세로보기 인 경우 세로보기입니다. – SOF