why is the landscape mode view still show width less then height?
try this,
say you have a simple landscape mode iphone app, like a simple viewcontroller app.
also uncomment the autorotate in viewcontroller .m file like so
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
NSLOG(@"width:%f,height:%f",self.view.frame.size.width,self.view.frame.开发者_运维百科size.height);
return YES;
}
after that, simply run the thing on iphone simulator, and try to rotate it by command+left or command+right.
I would expect that I get something like width:320.000,height:480.000 when in portrait and width:480.000,height:320.000 in the landscape mode.
instead, i always got width:320.000,height:480.000 what ever the actual orientation is.
so my question is what should i automatically get the view's size correctly?
Try getting the width/height in:
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
{
NSLog(@"view frame: %@",NSStringFromCGRect(self.view.frame));
}
Also your view needs to have UIAutoresizingMasks set in order to resize when rotated.
精彩评论