I have a view where I in manually in my code add 2 buttons as subview and place them at a specific location (lower right corner).开发者_如何学运维
How do i make them "stick" to the lower right corner when the view is resized? (on rotation)
Thanks
Did you try to set the autoresizingMask of your buttons ?
button.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleTopMargin;
It assumes that the autoresizesSubviews
property of the button's superview is set to YES
(that is the default value)
You should implement method
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
in your UIViewController
and manually change the frame of the button, changing the origin. i.e:
CGRect frame = button.frame;
frame.origin.x += 30;
frame.origin.y -= 20;
button.frame = frame;
精彩评论