I am making a view with several subviews for iPad. I want all the positioning and sizing of the subviews to stay the same when rotating the iPad, but the content inside the subviews to re-ori开发者_开发百科ent. Does anyone know how to do this?
It sounds like you still need to layout the views depending on the orientation. However, you're portrait and landscape frames would have different proportions on the screen.
An Example of how you might layout a view:
int h = 300;
int w = 100;
int space = 50;
CGRect frame;
if( interfaceOrientation == UIInterfaceOrientationPortrait ) {
frame = CGRectMake( space, space, w, h );
}
else if( interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown ) {
frame = CGRectMake( self.view.bounds.size.width - w - space, self.view.bounds.size.height- h - space, w, h );
}
else if( interfaceOrientation == UIInterfaceOrientationLandscapeRight ) {
frame = CGRectMake( space, self.view.bounds.size.height- w - space, h , w );
}
else if( interfaceOrientation == UIInterfaceOrientationLandscapeLeft ) {
frame = CGRectMake( self.view.bounds.size.width - h - space, space, h, w );
}
self.label.frame = frame;
精彩评论