I'm beginner in Xcode and I'm using ios6 with autolayout.
I would like to rotate my uiviewcontroller from:
to:
I would like to prevent my bottom bar from rotating. Something very similar to Apple's camera app rotation, but whats going wrong is that everything rotates.
I tried to put some code like
-(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration{
// [Bar setTransform:CGAffineTransformMakeRotation(M_PI / -2.0)];
// [Bar setTranslatesAutoresizingMaskIntoConstraints:YES];
}
I don't know how to achieve it by IB, but you can do that by adding specific constraints through code:
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
if (UIInterfaceOrientationIsPortrait(toInterfaceOrientation)) {
[self.view removeConstraints:landscapeConstraints];
} else {
[self.view addConstraints:landscapeConstraints];
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With