繁体   English   中英

在两种横向模式下,如何保持模态对话框接近顶部

[英]How do I keep my modal dialog close to the top in both landscape modes objective-c

我正在使用它来更改模式对话框的宽度和高度

- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterface {
     if (UIInterfaceOrientationIsLandscape(self.interfaceOrientation)) {

            self.view.superview.frame = CGRectMake(74, 170, 380.0f, 712.0f);

        }
}

self.view.superview.frame = CGRectMake(74, 170, 380.0f, 712.0f); 作品将在一个景观上显示,但是当您绕着iPad转动y时,位置会降低。 对于两个景观,它都必须位于相同的y位置。

编辑

这可以正常工作。 不确定是否是最佳答案。 会接受更好的答案。

if (UIInterfaceOrientationIsLandscape(self.interfaceOrientation)) {

            self.view.superview.frame = CGRectMake(174, 170, 380.0f, 712.0f);
            self.view.superview.transform = CGAffineTransformTranslate(self.view.superview.transform,0,-72);

        }

如果我们在这里谈论的是在PresentModalViewcontroller的帮助下呈现的UIVIewcontroller。 我们不应该更改视图控制器的高度和宽度。 苹果提供了演示样式: http : //developer.apple.com/library/ios/#documentation/UIKit/Reference/UIViewController_Class/Reference/Reference.html#//apple_ref/c/econst/UIModalPresentationFormSheet

另外,如果要创建自定义模式,则可以通过在简单UIView上使用CATransition进行过渡来创建。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM