Xcode 사용 4.2.1 iPad iOS 5.0.1에서 새로운 "단일보기"iPad 프로젝트를 만듭니다. ,회전 후 UIView 좌표는 바뀌지 만 UIWindow는 바뀌지 않습니까?
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return YES;
}
- (void) dumpView: (UIView *) view {
CGRect frame = view.frame ;
CGRect bounds = view.bounds ;
CGPoint center = view.center ;
NSLog(@"view [%@]:%d frame=%@ bounds=%@ center=%@"
, NSStringFromClass(view.class)
, [view hash]
, NSStringFromCGRect(frame)
, NSStringFromCGRect(bounds)
, NSStringFromCGPoint(center)) ;
}
- (void) didRotateFromInterfaceOrientation:(UIInterfaceOrientation) fromInterfaceOrientation {
NSLog(@"INViewController.didRotateFromInterfaceOrientation: %d to %d", fromInterfaceOrientation, self.interfaceOrientation) ;
[self dumpView: self.view] ;
[self dumpView: self.view.superview] ;
}
실행하여 장치를 회전하면 얻을 것이다 : 컨트롤러에 추가, 즉
INViewController.didRotateFromInterfaceOrientation: 2 to 4
view [UIView] bounds={{0, 0}, {1024, 748}} center={394, 512}
view [UIWindow] bounds={{0, 0}, {768, 1024}} center={384, 512}
을의 UIView의는 "가로로 교환"그 좌표가 예상대로,하지만 부모 UIWindow는 여전히 또한
는 UIView의 크기는 약간 틀린 것 같다 ... 세로 모드로 제기 : y는 (20)가 0에에 있어야하는 좌표 ...누구나 어 알고 이게 뭐야?
의미가 있습니다. 고맙습니다. 덧붙여, gdb가 대화식으로 실제로 사용될 수 있다는 것을 보여 주신 것에 대해서도 감사드립니다 .-) – verec
@rob UIView.frame의 ref 문서는 다음과 같이 말합니다 : 경고 transform 속성이 ID 변환이 아닌 경우이 속성의 값은 정의되지 않습니다. 따라서 무시해야합니다. 그것에 대해 자세히 설명해 주시겠습니까? 회전 된 뷰의 프레임에 애니메이션을 적용하여 오버레이로 슬라이드하려고한다고 가정 해 보겠습니다. – tribalvibes
'transform'이 아이덴티티가 아니라면'frame'을 코드에 의존하지 않습니다. 그러나,'frame' 메소드는 항상'[self convertRect : self.bounds toView : self.superview]'를 반환하는 것으로 보이므로 디버깅 할 때 유용합니다. –