0

我有一个与 UIAlertView 相关的问题。我创建了一个带有正文消息和两个按钮的警报,用于确定和取消。当我展示 alertWindow 时,按钮使其位置在警报窗口之外并且不可访问。当方向改变时它会变得正常。

我尝试通过更改 alertWindow 的大小,但问题存在。

这是我的代码

 UIAlertView *errorAlert=[[UIAlertView alloc]initWithTitle:errorAlertTitle message:errorAlertMessage  delegate:self cancelButtonTitle:errorAlertClose otherButtonTitles:@"Reload", nil];
     errorAlert.tag=2;
     errorAlert.frame = CGRectMake(0,0,500,600);

     [errorAlert show];
     [errorAlert release];

在此处输入图像描述

任何解决方案?

4

2 回答 2

1

When you write "alert window", you mean the visible portion of the UIAlertView that has text and buttons, right? Do you think that you are setting the frame of the "alert window" in your code? Are you actually setting the frame of a transparent blocking view that prevents the user from interacting with the rest of the UI and contains the "alert window"? The view hierarchy of UIAlertView is private, so we can't know for sure how it is structured, but you may be manipulating the wrong thing. Note that the documentation also warns against interfering with the UIAlertView view hierarchy, so you may not want to set any view properties like frame for your UIAlertView.

If you really want to modify the "alert window", you could:

  1. Analyze the subviews of the alert view by writing code to walk through them and log useful information (frame, type, etc.). This might tell you which subview you actually want to manipulate.

and then

  1. Use the callbacks in UIAlertViewDelegate to manipulate the alert window after the UIAlertView been constructed and is about to become visible.

But maybe you want to look into UIActionSheet or UIPopoverController if the automatic styling of UIAlertView is not working for you?

于 2012-08-03T05:04:02.987 回答
0

根据您的要求,我只是您使用操作表,但对于您的问题,请执行以下操作:

添加此代码:

 errorAlert.frame = CGRectMake(0,0,500,600);

[errorAlert show];
于 2012-08-03T04:43:00.220 回答