I am making app like whenever the device change it’s orientation mode it changes it’s view.
At first when the view is portrait it shows perfect SearchViewController, then when i rotate to landscape it push to new view MapView in landscape … now when i again change the view to portrait the map rotate to portrait… but it should be do to search view controller… and one more thing when i tapped detail disclosure button it should be go to back to search view controller… i think navigation controller not work in map view..
this is my code part of searchViewController
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
//return (interfaceOrientation == UIInterfaceOrientationPortrait);
if(interfaceOrientation == UIInterfaceOrientationPortrait|| inte rfaceOrientation == UIInterfaceOrientationPortraitUpsideDown)
{
}
else {
MapView *mapView = [[MapView alloc] initWithNibName:@"MapView" bundle:nil];
mapView.title = @"Map";
[self.navigationController pushViewController:mapView animated:YES];
return YES;
}
return YES;
}
and this is my MapView code
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
// return (interfaceOrientation == UIInterfaceOrientationLandscapeRight|| UIInterfaceOrientationLandscapeLeft);
if(interfaceOrientation == UIInterfaceOrientationPortrait|| interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown)
{
NSLog(@"hi Potrait");
[self.navigationController popViewControllerAnimated:NO];
return YES;
}
else {
}
return YES;
}
shouldAutorotateToInterfaceOrientation:is an incorrect place to implement any kind of navigation. You should do it indidRotateFromInterfaceOrientation:instead. Check the currentinterfaceOrientationand push or pop if necessary.In
searchViewController,In
MapView,And alter your
shouldAutorotateToInterfaceOrientation:to