I have an application in which I have apply facility to change orientation of view but when I change the orientation then go to next screen then there show a gap on right side if I rotate device in right side as show in image:
I use this code in viewcontroller.m:
-(void) viewWillAppear:(BOOL)animated{
UIInterfaceOrientation orientation = [[UIDevice currentDevice] orientation];
[self willAnimateRotationToInterfaceOrientation:orientation duration:0];
}
-(void) willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
if(toInterfaceOrientation == UIInterfaceOrientationPortrait || toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown )
{
lgo_imag.frame=CGRectMake(0, 0, 320, 44);
btn_settings.frame=CGRectMake(238, 3, 72, 37);
btn_alarm_activity.frame=CGRectMake(125, 10, 70, 85);
btn_alarm_screen.frame=CGRectMake(48, 210, 225, 55);
btn_routine_screen.frame=CGRectMake(48, 275, 225, 55);
btn_view_info.frame=CGRectMake(48, 340, 225, 55);
lable_alarm_value.frame=CGRectMake(25, 100, 270, 81);
scroll_view.frame=CGRectMake(0, 44, 320, 416);
scroll_view.contentSize=CGSizeMake(320 ,416);
}
else if(toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft || toInterfaceOrientation == UIInterfaceOrientationLandscapeRight )
{
lgo_imag.frame=CGRectMake(0, 0, 480, 44);
btn_settings.frame=CGRectMake(398, 3, 72, 37);
btn_alarm_activity.frame=CGRectMake(205, 10, 70, 85);
btn_alarm_screen.frame=CGRectMake(128, 210, 225, 55);
btn_routine_screen.frame=CGRectMake(128, 275, 225, 55);
btn_view_info.frame=CGRectMake(128, 340, 225, 55);
lable_alarm_value.frame=CGRectMake(125, 100, 270, 81);
scroll_view.frame=CGRectMake(0, 44, 480, 320);
scroll_view.contentSize=CGSizeMake(480 ,470);
}
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Overriden to allow any orientation.
return YES;
}
How fix that problem?