tit*_*aca 4 ipad modalviewcontroller uimodalpresentationformsh ios ios6
我想在iPad屏幕上表示modalviewcontrollers有问题.如果我保持原样大小,那么它就完全集中了.但我对这些视图的信息很少,所以我需要调整它们的大小.
所以,当我调整它们的大小时,我不能强迫它们出现在屏幕中间.即使我设法将其中一个中心放在一个方向上,它也会在另一个方向上混乱.
这是我目前的代码:
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:acvc];
[nav setModalPresentationStyle:UIModalPresentationFormSheet];
[nav setModalTransitionStyle: UIModalTransitionStyleCoverVertical];
[[acvc view] setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"main_bg.jpg"]]];
[self presentViewController:nav animated:YES completion:nil];
nav.view.superview.frame = CGRectMake(self.view.bounds.size.width/2 + 175, self.view.bounds.size.height/2 - 125, 350, 250);
// nav.view.superview.center = self.view.window.center;
Run Code Online (Sandbox Code Playgroud)
非常感谢任何帮助,谢谢.
这是一个适用于iOS7以及iOS6和iOS5 的方法,并且仍允许您使用UIModalTransitionStyleCoverVertical:
-(void)presentController:(UIViewController*)controller fromRootController:(UIViewController*)rootController withSize:(CGSize)size
{
UINavigationController* nav = [[UINavigationController alloc] initWithRootViewController:controller];
nav.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
nav.modalPresentationStyle = UIModalPresentationFormSheet;
[rootController presentModalViewController:nav animated:YES];
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0)
{
nav.view.superview.backgroundColor = [UIColor clearColor];
nav.view.bounds = CGRectMake(0, 0, size.width, size.height);
}
else
{
nav.view.superview.bounds = CGRectMake(0, 0, size.width, size.height);
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2710 次 |
| 最近记录: |