2010-07-05 4 views
2

내 응용 프로그램의 배경 이미지로 UIImageView가 있습니다.이 응용 프로그램은 조난중인 헬리콥터처럼 자동 회전합니다. 문제는 오리엔테이션 자동 회전 이미지가 모든 곳으로 이동하여 좋아하지 않는다는 것입니다. 그것은 단순한 텍스쳐이기 때문에 사용자는 자동 회전하지 않고 그 위치에 머물러있는 것을 선호합니다. 이것이 의미하는 바는 이미지를 전체 화면으로 유지하고 싶을 때 사용자가 전화를 돌리면 이미지가 90도 회전하기 때문에 나머지 이미지는 전화기가 아니라 이미지가 고정 된 것처럼 보입니다.자동 회전을 방지하려면 어떻게해야합니까?

+1

가 실제로 작동하는 솔루션을 받으셨어요? 나는 할 수 없다 ... (받아 들인 대답에 대한 코멘트를 보시오) –

답변

1

보기 컨트롤러에서 willAnimateRotationToInterfaceOrientation:duration: 메서드를 구현하고 UIImageView을 반대 방향으로 회전 해 볼 수 있습니다.

아래의 코드 내 머리의 상단에서, 나는 그것이 작동을 보장 할 수 없습니다 :

- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation duration:(NSTimeInterval)duration { 
    CGFloat angle = M_PI/2; // Figure out the proper angle 
    [UIView beginAnimations:nil context:NULL]; 
    [UIView setAnimationDuration:duration]; 
    imageview.transform = CGAffineTransformMakeRotation(angle); 
    [UIView commitAnimations]; 
} 
+0

이것이 정말로 효과가 있었나요? 나는 그것을 여기에서 시도하고있다 : http://stackoverflow.com/questions/7073296/ios-strange-behaviour-rotating-uiimageview-inside-uiview 점점 100 % 실패 –

0

나는 이미지 편집 - 소프트웨어에서 이미지를 회전하고 동적으로로드하는 것이 좋습니다. 이것은 앵글을 어지럽히는 것보다 훨씬 쉽습니다. (코드도 읽기 쉽습니다.) 이처럼

:

- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration { 

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

     myBackground.image = [UIImage imageNamed:@"bg.jpg"];    

    } else { // landscape view  

     myBackground.image = [UIImage imageNamed:@"bg_landscape.jpg"]; 

    } 
} 
관련 문제