2014-05-12 4 views

답변

0

다른 방법으로는 다음 위임 함수에서 프로그래밍 방식으로 프레임 및 기타 사항을 처리해야합니다. 가로 모드 용 코드 만 표시했습니다.

//THis only work for ios<6.0 
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 

    if(interfaceOrientation== UIInterfaceOrientationPortrait || interfaceOrientation==UIInterfaceOrientationPortraitUpsideDown) 
    { 
      return NO; 
    } 
    else 
    { 
      return YES; 
    } 
} 

//THis work for ios >=6.0 
- (BOOL)shouldAutorotate 
{ 
    return YES; 
} 
- (NSUInteger)supportedInterfaceOrientations 
{ 

    UIInterfaceOrientation interfaceOrientation=[[UIApplication sharedApplication] statusBarOrientation]; 

    if(interfaceOrientation== UIInterfaceOrientationPortrait || interfaceOrientation==UIInterfaceOrientationPortraitUpsideDown) 
    { 

     return NO; 
    } 
    else 
    {  
     //landscape mode code  
     return (UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight); 

} 



- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation 
{ 
    UIInterfaceOrientation orientation=self.interfaceOrientation; 

    if(orientation== UIInterfaceOrientationPortrait || orientation==UIInterfaceOrientationPortraitUpsideDown) 
    { 
     //portrait mode code 
    } 
    else 
    { 
     //landscape mode code 
    } 
} 
관련 문제