I have 2 UIToolbar in one ViewControler.
I need to change their positin on rotating.
I add 2 outlets
@property (nonatomic, retain) IBOutlet UIToolbar *toolbar1;
@property (nonatomic, retain) IBOutlet UIToolbar *toolbar2;
Connect them in IB Now in viewcontroller.m i use this code
- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
if (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft ||
toInterfaceOrientation == UIInterfaceOrientationLandscapeRight)
{
toolbar1.frame = CGRectMake(0, 0, 1024, 44);
toolbar2.frame = CGRectMake(0, 374, 1024, 44);
}
else
{
toolbar1.frame = CGRectMake(0, 0, 768, 44);
toolbar2.frame = CGRectMake(0, 502, 768, 44);
}
}
Promblem is - nothing changes!
How can i fix it?
P.S. With webviews it works
Make sure you Uncheck Autolayout in ViewController.xib, then this code always work. Change height to see different and comment out all setting in other method.
- (void)viewDidLayoutSubviews{
if (UIInterfaceOrientationIsLandscape(self.interfaceOrientation)){
toolbar1.frame = CGRectMake(0, 0, 1024, 20);
toolbar2.frame = CGRectMake(0, 374, 1024, 20);
} else {
toolbar1.frame = CGRectMake(0, 0, 768, 44);
toolbar2.frame = CGRectMake(0, 502, 768, 44);
}
}