0

1.This Image shows the "root view controller",If I clicks the "from" text box it shows the date picker properly.In story board "root view controller" in "cyan colour".

enter image description here

2.This Image shows the another "view controller",If I clicks the "start date" text box it shows the date picker properly.In story board "view controller" in "pink colour". enter image description here

3.This Image shows the another "view controller" with "cancel" button.On click "cancel" button it redirects to other controller.In story board "view controller" with "landscape orientation". enter image description here

My piece of code for redirecting to some other controller:

- (IBAction)btnCancel:(id)sender 
{
NSString * storyboardName=@"Main";
UIStoryboard *storyboard =[UIStoryboard storyboardWithName:storyboardName bundle:nil];
UITabBarController *tab =[storyboard instantiateViewControllerWithIdentifier:@"Bar"];
[self presentViewController:tab animated:NO completion:Nil];
}

After this scenario,Again I goto the previous pages,then select date picker it shows some other "orientation" or "angle".refer Below screen shots

4.After On click the "cancel" button,Then I goes to previous pages,then click "From" text box,the date picker shows in some other angle.

enter image description here

5.After On click the "cancel" button,Then I goes to previous pages,then click "start date" text box,the date picker shows in some other angle.

enter image description here

6.This Image shows screen shot of story board for these controllers.

enter image description here

I thought that redirecting to some other pages causes this issue.How to solve this through UI Storyboard or programatically.Please give any ideas to me.Thanks in advance.

djonthe
  • 27
  • 5

1 Answers1

0

When your last viewcontroller present in landscape your app orientation changed and not reversed to the actual orientation. You need to implement these methods in your viewControllers to stay in proper orientation

- (BOOL)shouldAutorotate {
      return NO;
}
-(NSUInteger)supportedInterfaceOrientations
{
    return your Required Interface Orientations;
}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
    return your Required Interface Orientations;
}

and set this property of your datepicker

yourPickerView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleTopMargin;

and if you need to show only one viewcontroller in landscape and others in portrait check this link to help

Only One View in LandScape

Community
  • 1
  • 1
Waris Shams
  • 1,606
  • 1
  • 15
  • 27
  • thanks for the help bro i just changed the landscape controller- return "yes" to "no" now it works fine bro.. (BOOL)shouldAutorotate { return NO; } – djonthe Mar 14 '16 at 07:33