我的项目在它使用的几个地方都有现有代码,navigationController.view.superview.frame
并navigationController.view.superview.center
在当前视图的顶部调整和居中模式视图。当然,我可以将它们用作样板,但老实说,我不知道navigationController.view.superview
真正指的是什么。是特别的UINavigationControllers
吗?任何想法/意见将不胜感激。
[编辑] 这是代码:
UIStoryboard *sb = self.storyboard;
MyViewController *vc = (MyViewController *)[sb instantiateViewControllerWithIdentifier:@"MyLoginViewController"];
vc.delegate= self;
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:vc];
navController.modalPresentationStyle = UIModalPresentationFormSheet;
[self.navigationController presentModalViewController:navController animated:YES];
navController.view.superview.frame = CGRectMake(
navController.view.superview.frame.origin.x,
navController.view.superview.frame.origin.y,
400.0f,
400.0f
);
navController.view.superview.center = self.view.center;
如果我不为新的模态视图使用导航控制器,我就不必使用“superview”。即,
UIStoryboard *sb = self.storyboard;
MyViewController *vc = (MyViewController *)[sb instantiateViewControllerWithIdentifier:@"MyLoginViewController"];
vc.delegate= self;
[self.navigationController presentModalViewController:vc animated:YES];
vc.view.frame = CGRectMake(
vc.view.frame.origin.x,
vc.view.frame.origin.y,
400.0f,
400.0f
);
vc.view.center = self.view.center;
但是,我将无法在后台查看呈现的 vc ......