Set Interface Builder Object Coordinates in XCode
First question on StackOverflow, so please excuse me if I haven't done all the proper steps, although I've tried searching for an answer for a while now.
I'm trying to change the coordinates of multiple objects in a UIView from Interface Builder when the iPhone changes from portrait mode to landscape mode. I don't want so scale the view, but I want to rearrange the objects in it when the iPhone turns into landscape mode, so that all the objects will fit better. Currently I'm looking for a way to programmatically set the X,Y coordinates, but if there is a better way to go about doing this, let me know.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
if (UIInterfaceOrientationIsLandscape(interfaceOrientation)) {
/* Move IBOutlets to diff开发者_运维知识库erent X,Y coordinates */
}
return YES;
shouldAutorotateToInterfaceOrientation:
should only be used the answer the question of whether the view supports a particular orientation. Use willRotateToInterfaceOrientation:
or didRotateFromInterfaceOrientation
to rearrange objects.
Actually, it would probably be even better to subclass UIView
and override layoutSubviews
.
精彩评论