- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation{
return YES;
}
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
[self positionViews];
}
-(void)positionViews {
UIInterfaceOrientation destOrientation = self.interfaceOrientation;
if (destOrientation == UIInterfaceOrientationPortrait ||
destOrientation == UIInterfaceOrientationPortraitUpsideDown) {
[bLabel setFrame:CGRectMake(255, 10, 270, 60)];
} else {
[bLabel setFrame:CGRectMake(377, 10, 270, 60)];
}
}
bLabel
is Cutomed Object.
When IPad(device) rotates, bLable
is rotated.
But appear time lag.
So rotation motion is not smooth.
What is my code's faults? How control autosizing of object without IB naturally?
Please tell me your advice. Thanks!!!
The property you are looking for on the view is autoresizingMask.Set this just as you would in IB. Here are the values available:
UIViewAutoresizing
Specifies how a view is automatically resized.
enum {
UIViewAutoresizingNone = 0,
UIViewAutoresizingFlexibleLeftMargin = 1 << 0,
UIViewAutoresizingFlexibleWidth = 1 << 1,
UIViewAutoresizingFlexibleRightMargin = 1 << 2,
UIViewAutoresizingFlexibleTopMargin = 1 << 3,
UIViewAutoresizingFlexibleHeight = 1 << 4,
UIViewAutoresizingFlexibleBottomMargin = 1 << 5
};
For example, if you want a flexible width and height with fixed margins you would do:
[myView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoResizingFlexibleWidth;][1]