2012-11-13 2 views
3

작동하는 기능 페이지 컬이 있습니다. 문제는 iPad의 교체입니다. 앱은 가로 방향으로 만 실행되며 왼쪽과 오른쪽을 지원합니다. iPad가 '풍경 오른쪽'인 경우 컬이 오른쪽 하단에서 발생합니다. iPad를 회전하면 뷰가 예상대로 회전하지만 지금은 왼쪽 상단에서 컬이 발생합니다. 회전 할 때 알림을 추가하고 애니메이션 하위 유형을 변경하려고 시도했지만 주사위를 변경하지 않았습니다.iPad에서 방향 전환을 준수하지 않는 CAT 전환

-(IBAction)curlViewUp 
{ 
    uiv_help.alpha = 1.0; 

    [UIView animateWithDuration:1.0 
        animations:^{ 
         CATransition *animation = [CATransition animation]; 
         [animation setDelegate:self]; 
         [animation setDuration:0.7]; 
         [animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]]; 
         animation.type = @"pageCurl"; 
         animation.subtype = curlDirection; 
         animation.fillMode = kCAFillModeForwards; 
         animation.endProgress = 0.20; 
         [animation setRemovedOnCompletion:NO]; 
         [self.view.layer addAnimation:animation forKey:@"pageCurlAnimation"]; 
         [self.view addSubview:uiv_help]; 
         ;} 
    ]; 
} 

-(IBAction)curlViewDown 
{ 
    uiv_help.alpha = 0.0; 

    [UIView animateWithDuration:1.0 
        animations:^{ 
         CATransition *animation = [CATransition animation]; 
         [animation setDelegate:self]; 
         [animation setDuration:0.7]; 
         [animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut]]; 
         animation.type = @"pageUnCurl"; 
         animation.subtype = curlDirection; 
         animation.fillMode = kCAFillModeForwards; 
         animation.startProgress = 0.80; 
         [animation setRemovedOnCompletion:YES]; 
         [self.view.layer addAnimation:animation forKey:@"pageUnCurlAnimation"]; 
         //[self.view removeFromSuperview]; 
         [uiv_help removeFromSuperview]; 
         ;} 
    ]; 

} 

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
    return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft | interfaceOrientation == UIInterfaceOrientationLandscapeRight); 
} 

-(void)checkRotation:(NSNotification*)notification 
{ 
    UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation; 
    if(orientation == UIInterfaceOrientationLandscapeLeft) 
    { 
     NSLog(@"UIInterfaceOrientationLandscapeLeft"); 

     curlDirection = @"fromRight"; 
    } else if (orientation == UIInterfaceOrientationLandscapeRight) { 
     NSLog(@"UIInterfaceOrientationLandscapeRight"); 

     curlDirection = @"fromRight"; 
    } 
} 
+0

나는 그것이 Uikit 버그 또는 뭔가 일 것임에 틀림 없다고 생각한다. – jonydep

+0

StackOverflow에 복사했을 때의 오타 였을지 모르지만 여기에 curlDirection = @ "fromRight"라고 표시된다. 방향이 왼쪽 또는 오른쪽인지. –

+0

사람들은 왜 그들을 따라갈 의도가 없을 때 현상금을 제공합니까? – foundry

답변

3

사용자의 페이지가 장치와 함께 회전하고 있지 않습니다.

그것의 시각이보기 뷰 계층의 최상위 도면 때문에

이다 .. 장치와 함께 회전하는 회전되지 않기 때문이다.

어디서나 설명서를 찾을 수 없지만 다른 사람이 찾아 낼 수 있습니까? 그럼에도 불구하고보기 계층 구조의 가장 바깥 쪽보기가 회전하지 않습니다. 나는 그것이 다른 모든 것을 회전시키는 것이 책임이라는 관점에 있기 때문이라고 생각합니다 (또는 어떤 관점의 회전 변환이 적용되는이 뷰).

이것은보기의 프레임과 경계를 기록하고 순환 게재에서 일어나는 일을 감시하는 간단한 방법입니다.

여기에 우리는 인물 모드입니다. 동일한 치수로 self.view 내부에 포함 된 하위 뷰를 설정했습니다.

self.view frame {{0, 20}, {768, 1004}} 
self.view bounds {{0, 0}, {768, 1004}} 
self.view center {384, 522} 
-------- 
self.subview frame {{0, 0}, {768, 1004}} 
self.subview bounds {{0, 0}, {768, 1004}} 
self.subview center {384, 502} 

지금 풍경

self.view frame {{20, 0}, {748, 1024}} 
self.view bounds {{0, 0}, {1024, 748}} 
self.view center {394, 512} 
-------- 
self.subview frame {{0, 0}, {1024, 748}} 
self.subview bounds {{0, 0}, {1024, 748}} 
self.subview center {512, 374} 

당신이 내부 서브 뷰가 제대로 748px로 1024 폭과 높이를보고하는 것을 볼에 회전 할 수 있습니다. 하지만 외부보기가 그냥 이상하게되었습니다. 그것은 프레임의 너비가 748이고 높이가 1024인데 여전히 세로 인 것처럼 보입니다 (상태 표시 줄 20px 추가). 하지만 그것은 경계입니다. 그것이 풍경입니다.

우리는 분명히 이상한 결과를보고하는 뷰의 기하학적 속성에 의존하기를 원하지 않습니다. 이것이 아이덴티티 변환이 아닌 다른 변환의 대상인 경우 뷰 프레임을 참조하면 안된다는 Apple의 경고와 관련이 있다고 생각합니다.

해결 방법은 pagecurling 뷰를 다른 가장 바깥 쪽 뷰에 포함시키는 것입니다. 새로운 뷰를 생성하고 self.subview (또는 무엇이든)라고 부르며 뷰 계층 구조에 self.view의 유일한 자식으로 추가합니다. self.view와 같은 rect에 크기를 지정하십시오. self.view 대신 self.subview에서 작동하십시오.

변경이 라인 :

[self.view.layer addAnimation:animation forKey:@"pageCurlAnimation"]; 

[self.subview.layer addAnimation:animation forKey:@"pageCurlAnimation"]; 

와이 라인 변경 :

[self.view.layer addAnimation:animation forKey:@"pageUnCurlAnimation"]; 

에 :

[self.subview.layer addAnimation:animation forKey:@"pageUnCurlAnimation"]; 
,369을

그러면 원하는대로 회전하는보기에 적용하기 때문에 컬이 예상 한대로 작동합니다.

코드를 변경하지 않고도 동일한 결과를 얻을 수 있지만 UINavigationViewController에 viewController를 포함해야합니다. 이 경우 NavViewController의 뷰는 회전하지 않는 가장 바깥 쪽 뷰입니다. 그래서 당신 self.view 회전합니다. (가) 변환

갱신

UIWindow* mWindow = [[UIApplication sharedApplication] keyWindow]; 
UIView *topView = [[mWindow subviews] lastObject]; 
NSLog("%@",topView); 


topView <UILayoutContainerView: 0x71eb450; 
frame = (0 0; 748 1024); 
transform = [0, 1, -1, 0, 0, 0];  
autoresize = W+H; gestureRecognizers = <NSArray: 0x71f8a30>; 
layer = <CALayer: 0x71eb540>> 

참고.

+0

불행히도 UINavigationViewController 전혀 도움이되지 않습니다. navcontroller pushviewController에 컬 전환을 적용하면 잘못된 동작이 발생합니다. 컬은 장치 방향을 무시합니다. –