views:

29

answers:

1

I have a case where a portrait only mode view needs to be pushed into a navigation controller which has a landscape mode view as its current view.

Although I have reimplemented

-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation   {
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

but it is still pushing the view in landscape mode. I have also tried the following way, but even this is not working.

- (void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];
    [[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationPortrait animated:YES];
}

I tried looking into other related questions but did not find anything.

Any idea how I can solve this?

Thanks!

A: 

Your best bet is to just use a modal view controller instead which forces the view to be in portrait regardless of device orientation.

If you want to wrap a navigation controller around it to keep styling consistent, look at Apple's Core Data Recipes example for how they do this when you add a new recipe.

iWasRobbed