3

2 개의 이미지가 세로 모드와 가로 모드로 있습니다. 모바일 장치보기 회전이 발생할 때 이러한 이미지를 전환하는 가장 좋은 방법은 무엇입니까?iphone/ipad의 이미지 회전을 처리하는 적절한 방법은 무엇입니까?

현재 인물 사진을 표시합니다. 또한 장치가 가로 모드로 회전하면 인물 이미지가 단순히 늘어납니다.

오리엔테이션 회전 핸들러에서 확인하고 이미지를 적절한 방향 이미지로 재설정해야합니까 (즉, 방향에 따라 수동으로 설정해야합니까?) ??

감사합니다. 자동 크기

예 :

UIImageView *myImageView=[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"yourImage.png"]];  
myImageView.frame = self.view.bounds; 
myImageView.autoresizingMask=UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight 
myImageView.contentMode = UIViewContentModeScaleAspectFill;  
[self.view addSubview:myImageView]; 
[imageView release]; 

2 : CGAffineTransformMakeRotation

예 :

답변

2

나는 세 ways.I이 마지막이 더

한 생각 발견

-(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation 
             duration:(NSTimeInterval)duration { 
    if (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft) {   
       myImageView.transform = CGAffineTransformMakeRotation(M_PI/2); 
    } 
    else if (toInterfaceOrientation == UIInterfaceOrientationLandscapeRight){ 
       myImageView.transform = CGAffineTransformMakeRotation(-M_PI/2); 
    } 
    else { 
      myImageView.transform = CGAffineTransformMakeRotation(0.0); 
    } 
} 

3 : 자동으로 myImageView의 설정 자동 크기 조절이 인터페이스 빌더에서 화면을 채우기

예 :

-(void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation { 
if((self.interfaceOrientation == UIDeviceOrientationLandscapeLeft) || (self.interfaceOrientation == UIDeviceOrientationLandscapeRight)){ 
    myImageView.image = [UIImage imageNamed:@"myImage-landscape.png"]; 
} else  if((self.interfaceOrientation == UIDeviceOrientationPortrait) || (self.interfaceOrientation == UIDeviceOrientationPortraitUpsideDown)){ 
    myImageView.image = [UIImage imageNamed:@"myImage-portrait.png"]; 
} } 

보고 더 솔루션 here

developer.apple 솔루션은 here

입니다