【发布时间】:2011-12-22 01:05:33
【问题描述】:
使用 Xcode 4.2.1 iPad iOS 5.0.1,创建一个新的“Single View”iPad 项目。在控制器中,添加:
- (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 的大小似乎有点不对:应该在 20 的 y 坐标在 0 ...
有人知道这是什么意思吗?
【问题讨论】:
标签: ios uiview rotation uiwindow