我可以移动UIAlertView吗? [英] Can I move a UIAlertView?

查看:75
本文介绍了我可以移动UIAlertView吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在提高警报视图,所以我也可以在屏幕上安装键盘。我只是通过抓住警报的框架并在我已经显示警报之后更改Y来做到这一点,以便框架变量是合法的。这在模拟器上工作正常,但是当我在硬件上执行此操作时,警报从正确的位置开始,但几乎立即跳到它的原始垂直中心位置。 UIAlertView位置是一个固定的东西,根据可用性指南不应该改变,或者我只是做错了什么?

I've been moving an alert view slightly higher so i can fit a keyboard on screen as well. I just do this by grabbing the frame of the alert and changing the Y after i have already shown the alert so that the frame variables are legit. This works fine on the simulator, but when I do this on the hardware, the alert starts at the correct position but then almost immediately jumps down to it's original vertical center place. Is the UIAlertView position a fixed thing that isn't supposed to change per the usability guidelines or am i just doing something incorrectly?

谢谢!

推荐答案

您正在尝试使用哪种操作系统?我让它在OS 3.0模拟器和OS 3.0设备上工作:

What OS are you trying this against? I got this to work on both the OS 3.0 Simulator and OS 3.0 Device:

UIAlertView * alert = [ [ UIAlertView alloc ] initWithTitle:@"Alert" message:@"Alert" 
                        delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil ];

alert.transform = CGAffineTransformTranslate( alert.transform, 0.0, 100.0 );

[ alert show ];

CGAffineTransformTranslate 有三个参数:现有转换,x变换和ay变换。在我使用的示例中,警报视图比正常情况高出100个像素。尝试一下,看看会发生什么。

CGAffineTransformTranslate takes three arguments: the existing transform, an x transform, and a y transform. In the example I used, the alert view appeared 100 pixels higher than it normally would. Give this a try and see what happens.

另外,我很确定你可以在显示警告之前修改帧,因为它可能会在<?中设置警报的帧code> init 默认为整个屏幕的中心。

Also, I'm pretty certain you can modify the frame before showing the alert as it likely sets up the alert's frame in init to be the center of the entire screen by default.

这篇关于我可以移动UIAlertView吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆