Após a rotação, as coordenadas UIView são trocadas, mas as UIWindow não são?
Usando o Xcode 4.2.1 iPad iOS 5.0.1, crie um novo projeto para iPad "Single View". No controlador, adicione:
- (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] ;
}
Execute, gire o dispositivo e você obterá:
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}
Em outras palavras, o UIView tem suas coordenadas "trocadas para paisagem" conforme o esperado, mas seu UIWindow pai ainda afirma estar no modo retrato ...
Além disso, o tamanho do UIView parece estar um pouco errado: a coordenada y, que deve estar em 20, está em 0 ...
Alguém sabe o que isso significa?