1

我在 iPad 上有一个 UIViewController,我正在模态显示。

然而,在关闭它之后,显示它的视图控制器不会改变方向,并且就像底层视图控制器没有改变一样,除非设备来回旋转。

我在模态视图控制器中使用这些方法:

- (BOOL)shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation)interfaceOrientation {
  [self updateUI];
    return YES;
}

- (BOOL)shouldAutorotate {
  [self updateUI];
    return YES;
}

-(NSUInteger)supportedInterfaceOrientations{
  return UIInterfaceOrientationMaskAll;
}

-(void) updateUI{

}

底层的 UINavigationController 代码(一旦模式视图控制器被解除,它就不会正确地改变自己):

- (BOOL)shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation)interfaceOrientation {
  [self adjustUIForOrientation:interfaceOrientation];
    return YES;
}

- (BOOL)shouldAutorotate {
  [self adjustUIForOrientation:[self preferredInterfaceOrientationForPresentation]];
    return YES;
}

-(NSUInteger)supportedInterfaceOrientations{
  return UIInterfaceOrientationMaskAll;
}


- (void) adjustUIForOrientation: (UIInterfaceOrientation)interfaceOrientation {
  if(UIDeviceOrientationIsPortrait(interfaceOrientation)) {
    [_landscapeTemplate hide];
    [_portraitTemplate show];
    _activeTemplate = _portraitTemplate;
  } else {
    [_portraitTemplate hide];
    [_landscapeTemplate show];
    _activeTemplate = _landscapeTemplate;
  }
}

-(IBAction) signInButtonTouched: (id) sender{
  if (![Session shared].loggedInUser){
    UserProfileLoginViewController *userProfileLoginVC = [[[UserProfileLoginViewController alloc] initWithNibName:@"UserProfileLoginViewController" bundle:nil] autorelease];
    userProfileLoginVC.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
    self.modalPresentationStyle = UIModalPresentationCurrentContext;
    //self.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
    [self presentViewController:userProfileLoginVC animated:YES completion:nil];

     // [self pushViewController:userProfileLoginVC animated:YES];
    [userProfileLoginVC.emailTextField becomeFirstResponder];
  }
  else [[Session shared] explicitEnd];
}

有没有办法使这项工作?基本上,呈现模态视图控制器的视图控制器似乎没有将旋转调用转发给自己。

4

0 回答 0