1

I am trying to disable rotation for just a single viewController in iOS, i have see some questions asked for auto rotate but none for this.

I want to lock the orientation that View B opens into For ex: opens in landscape, it can only be landscape, or opens in portrait, it can only be portrait. While still allowing view A to be whatever orientation it wants.

EDIT \n This is how i call view B

    [self.mediaFocusController showImageFromURL:url fromView:self.view withThumb:thumbUrl];

This is how it enters:

if (self.targetViewController) {
    [self willMoveToParentViewController:self.targetViewController];
    if ([UIView instancesRespondToSelector:@selector(setTintAdjustmentMode:)]) {
        self.targetViewController.view.tintAdjustmentMode = UIViewTintAdjustmentModeDimmed;
        [self.targetViewController.view tintColorDidChange];
    }
    [self.targetViewController addChildViewController:self];
    [self.targetViewController.view addSubview:self.view];

    if (self.snapshotView) {
        [self.targetViewController.view insertSubview:self.snapshotView belowSubview:self.view];
        [self.targetViewController.view insertSubview:self.blurredSnapshotView aboveSubview:self.snapshotView];
    }
}
else {
    // add this view to the main window if no targetViewController was set
    if ([UIView instancesRespondToSelector:@selector(setTintAdjustmentMode:)]) {
        self.keyWindow.tintAdjustmentMode = UIViewTintAdjustmentModeDimmed;
        [self.keyWindow tintColorDidChange];
    }
    [self.keyWindow addSubview:self.view];

    if (self.snapshotView) {
        [self.keyWindow insertSubview:self.snapshotView belowSubview:self.view];
        [self.keyWindow insertSubview:self.blurredSnapshotView aboveSubview:self.snapshotView];
    }
}

I have NavigationController set up but this view is different

inVINCEable
  • 2,167
  • 3
  • 25
  • 49
  • How does view controller B enter the view hierarchy? Do you have a navigation controller? tab controller? presented view controller? what? – matt Oct 14 '14 at 18:20

1 Answers1

0

Trying this code (I found that in https://stackoverflow.com/a/17377221/2040992):

- (BOOL)shouldAutorotate
{
    id currentViewController = self.topViewController;

    if ([currentViewController isKindOfClass:[DetailViewController class]])
        return NO;

    return YES;
}
Community
  • 1
  • 1
Sampayo
  • 38
  • 1
  • 9